Perform the following steps to perform dimension reduction using SVD:
- First, you can perform svd on the swiss dataset:
> swiss.svd = svd(swiss)
- You can then plot the percentage of variance explained and the cumulative variance explained in accordance with the SVD column:
> plot(swiss.svd$d^2/sum(swiss.svd$d^2), type="l", xlab=" Singular vector", ylab = "Variance explained")
> plot(cumsum(swiss.svd$d^2/sum(swiss.svd$d^2)), type="l", xlab="Singular vector", ylab = "Cumulative percent of variance explained")
- Next, you can reconstruct the data ...