diff --git a/inst/scripts/simple_spectra-trait_plsr_example.R b/inst/scripts/simple_spectra-trait_plsr_example.R index cb68887..2b7005a 100644 --- a/inst/scripts/simple_spectra-trait_plsr_example.R +++ b/inst/scripts/simple_spectra-trait_plsr_example.R @@ -187,7 +187,7 @@ plsr_data.output <- data.frame(plsr_data[, which(names(plsr_data) %notin% "Spect plsr_data.output <- plsr_data.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(plsr_data.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(plsr_data.output$PLSR_CV_Residuals^2)),2) rng_quant <- quantile(plsr_data.output[,inVar], probs = c(0.001, 0.999)) diff --git a/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_example.R b/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_example.R index fc2966b..1f23607 100644 --- a/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_example.R +++ b/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_example.R @@ -209,7 +209,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -219,7 +219,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -345,7 +345,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/inst/scripts/spectra-trait_kit_sla_plsr_example.R b/inst/scripts/spectra-trait_kit_sla_plsr_example.R index 5b4ad97..f1562e0 100644 --- a/inst/scripts/spectra-trait_kit_sla_plsr_example.R +++ b/inst/scripts/spectra-trait_kit_sla_plsr_example.R @@ -235,7 +235,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -245,7 +245,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -371,7 +371,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/inst/scripts/spectra-trait_neon_leafN_canopy_plsr_example.R b/inst/scripts/spectra-trait_neon_leafN_canopy_plsr_example.R index 8666c5b..9a6709a 100644 --- a/inst/scripts/spectra-trait_neon_leafN_canopy_plsr_example.R +++ b/inst/scripts/spectra-trait_neon_leafN_canopy_plsr_example.R @@ -272,7 +272,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -282,7 +282,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -412,7 +412,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/inst/scripts/spectra-trait_neon_lma_plsr_example.R b/inst/scripts/spectra-trait_neon_lma_plsr_example.R index 48474e0..b697d09 100644 --- a/inst/scripts/spectra-trait_neon_lma_plsr_example.R +++ b/inst/scripts/spectra-trait_neon_lma_plsr_example.R @@ -236,7 +236,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -246,7 +246,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -376,7 +376,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/inst/scripts/spectra-trait_reseco_leafN_plsr_bootstrap_example.R b/inst/scripts/spectra-trait_reseco_leafN_plsr_bootstrap_example.R index 8a2c0e8..12a7348 100644 --- a/inst/scripts/spectra-trait_reseco_leafN_plsr_bootstrap_example.R +++ b/inst/scripts/spectra-trait_reseco_leafN_plsr_bootstrap_example.R @@ -237,7 +237,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out, intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -247,7 +247,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data, intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -372,7 +372,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/inst/scripts/spectra-trait_reseco_leafN_plsr_example.R b/inst/scripts/spectra-trait_reseco_leafN_plsr_example.R index bbf4e9a..c8262b3 100644 --- a/inst/scripts/spectra-trait_reseco_leafN_plsr_example.R +++ b/inst/scripts/spectra-trait_reseco_leafN_plsr_example.R @@ -239,7 +239,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out, intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -249,7 +249,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data, intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -377,7 +377,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/inst/scripts/spectra-trait_reseco_lma_plsr_example.R b/inst/scripts/spectra-trait_reseco_lma_plsr_example.R index 1262848..d28063f 100644 --- a/inst/scripts/spectra-trait_reseco_lma_plsr_example.R +++ b/inst/scripts/spectra-trait_reseco_lma_plsr_example.R @@ -288,7 +288,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out, intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -298,7 +298,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data, intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -447,7 +447,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/ely_leafN_bootstrap_plsr_example.Rmd b/vignettes/ely_leafN_bootstrap_plsr_example.Rmd index 9619c38..17a4d0a 100644 --- a/vignettes/ely_leafN_bootstrap_plsr_example.Rmd +++ b/vignettes/ely_leafN_bootstrap_plsr_example.Rmd @@ -4,9 +4,9 @@ author: "Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson" output: github_document: default html_notebook: default + pdf_document: default html_document: df_print: paged - pdf_document: default params: date: !r Sys.Date() --- @@ -211,7 +211,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -221,7 +221,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -355,7 +355,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/ely_leafN_bootstrap_plsr_example.md b/vignettes/ely_leafN_bootstrap_plsr_example.md index 17b5820..9910579 100644 --- a/vignettes/ely_leafN_bootstrap_plsr_example.md +++ b/vignettes/ely_leafN_bootstrap_plsr_example.md @@ -103,7 +103,7 @@ inVar <- "N_g_m2" ### Set working directory (scratch space) - ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpqlTXi1" + ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpTADBVi" ### Full PLSR dataset @@ -448,7 +448,7 @@ head(cal.plsr.output) ## 10 Cal 1.358638 1.365181 0.06107105 ``` r -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -476,7 +476,7 @@ head(val.plsr.output) ## 15 Val 1.1267054 0.002059572 ``` r -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -677,7 +677,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) @@ -752,7 +752,7 @@ write.csv(out.jk.coefs,file=file.path(outdir,paste0(inVar, print(paste("Output directory: ", outdir)) ``` - ## [1] "Output directory: /var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T//RtmpqlTXi1" + ## [1] "Output directory: /var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T//RtmpTADBVi" ``` r # Observed versus predicted diff --git a/vignettes/ely_leafN_bootstrap_plsr_example.pdf b/vignettes/ely_leafN_bootstrap_plsr_example.pdf index cec72bc..e1963d1 100644 Binary files a/vignettes/ely_leafN_bootstrap_plsr_example.pdf and b/vignettes/ely_leafN_bootstrap_plsr_example.pdf differ diff --git a/vignettes/ely_leafN_bootstrap_plsr_example_files/figure-gfm/unnamed-chunk-11-1.png b/vignettes/ely_leafN_bootstrap_plsr_example_files/figure-gfm/unnamed-chunk-11-1.png index 5bce084..0257f75 100644 Binary files a/vignettes/ely_leafN_bootstrap_plsr_example_files/figure-gfm/unnamed-chunk-11-1.png and b/vignettes/ely_leafN_bootstrap_plsr_example_files/figure-gfm/unnamed-chunk-11-1.png differ diff --git a/vignettes/kit_sla_plsr_example.Rmd b/vignettes/kit_sla_plsr_example.Rmd index 8a826a8..686c81a 100644 --- a/vignettes/kit_sla_plsr_example.Rmd +++ b/vignettes/kit_sla_plsr_example.Rmd @@ -3,10 +3,10 @@ title: Spectra-trait PLSR example using leaf-level spectra and specific leaf are author: "Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson" output: github_document: default - pdf_document: default - html_notebook: default html_document: df_print: paged + html_notebook: default + pdf_document: default params: date: !r Sys.Date() --- @@ -229,7 +229,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -239,7 +239,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -372,7 +372,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/kit_sla_plsr_example.md b/vignettes/kit_sla_plsr_example.md index 80f27f3..8050953 100644 --- a/vignettes/kit_sla_plsr_example.md +++ b/vignettes/kit_sla_plsr_example.md @@ -85,7 +85,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "Output directory: /private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/Rtmpm4d2mF" + ## [1] "Output directory: /private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpktUPJx" ### Grab data from EcoSIS @@ -626,7 +626,7 @@ head(cal.plsr.output) ## 6 277.2292 274.2644 -113.974044 ``` r -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -654,7 +654,7 @@ head(val.plsr.output) ## 47 274.2311 -37.170622 ``` r -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -849,7 +849,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/kit_sla_plsr_example.pdf b/vignettes/kit_sla_plsr_example.pdf index 0f684d9..b5d193a 100644 Binary files a/vignettes/kit_sla_plsr_example.pdf and b/vignettes/kit_sla_plsr_example.pdf differ diff --git a/vignettes/kit_sla_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png b/vignettes/kit_sla_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png index 9c6ce33..f16f732 100644 Binary files a/vignettes/kit_sla_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png and b/vignettes/kit_sla_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png differ diff --git a/vignettes/neon_leafN_canopy_plsr_example.Rmd b/vignettes/neon_leafN_canopy_plsr_example.Rmd index 5b4fdca..34ef6f1 100644 --- a/vignettes/neon_leafN_canopy_plsr_example.Rmd +++ b/vignettes/neon_leafN_canopy_plsr_example.Rmd @@ -2,11 +2,11 @@ title: Spectra-trait PLSR example using NEON AOP pixel spectra and field-sampled leaf nitrogen content from CONUS NEON sites author: "Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson" output: - github_document: default - html_notebook: default pdf_document: default + html_notebook: default html_document: df_print: paged + github_document: default params: date: !r Sys.Date() --- @@ -263,7 +263,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -273,7 +273,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -407,7 +407,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/neon_leafN_canopy_plsr_example.md b/vignettes/neon_leafN_canopy_plsr_example.md index acd7a5b..e5c134a 100644 --- a/vignettes/neon_leafN_canopy_plsr_example.md +++ b/vignettes/neon_leafN_canopy_plsr_example.md @@ -83,7 +83,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpdmSKEo" + ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpvNSAkI" ### Grab data from EcoSIS @@ -550,7 +550,7 @@ head(cal.plsr.output) ## 8 25.56637 25.29798 -8.3333884 ``` r -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -578,7 +578,7 @@ head(val.plsr.output) ## 20 31.93483 2.432274 ``` r -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -743,7 +743,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/neon_leafN_canopy_plsr_example.pdf b/vignettes/neon_leafN_canopy_plsr_example.pdf index 476317f..9ac17a6 100644 Binary files a/vignettes/neon_leafN_canopy_plsr_example.pdf and b/vignettes/neon_leafN_canopy_plsr_example.pdf differ diff --git a/vignettes/neon_leafN_canopy_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png b/vignettes/neon_leafN_canopy_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png index fa7323d..aca3992 100644 Binary files a/vignettes/neon_leafN_canopy_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png and b/vignettes/neon_leafN_canopy_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png differ diff --git a/vignettes/neon_lma_plsr_example.Rmd b/vignettes/neon_lma_plsr_example.Rmd index 7bd4c65..34f3a22 100644 --- a/vignettes/neon_lma_plsr_example.Rmd +++ b/vignettes/neon_lma_plsr_example.Rmd @@ -2,11 +2,11 @@ title: Spectra-trait PLSR example using leaf-level spectra and leaf mass per area (LMA) data from CONUS NEON sites author: "Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson" output: - github_document: default pdf_document: default - html_notebook: default html_document: df_print: paged + html_notebook: default + github_document: default params: date: !r Sys.Date() --- @@ -227,7 +227,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -237,7 +237,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -384,7 +384,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/neon_lma_plsr_example.md b/vignettes/neon_lma_plsr_example.md index ab14201..a11b0d4 100644 --- a/vignettes/neon_lma_plsr_example.md +++ b/vignettes/neon_lma_plsr_example.md @@ -81,7 +81,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpBqQmIh" + ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpRBdgMm" ### Grab data from EcoSIS @@ -512,7 +512,7 @@ head(cal.plsr.output) ## 6 96.86039 15.190390 ``` r -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -540,7 +540,7 @@ head(val.plsr.output) ## 4928 65.94687 4.54686556 ``` r -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -749,7 +749,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data, intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/neon_lma_plsr_example.pdf b/vignettes/neon_lma_plsr_example.pdf index 285b112..e03264f 100644 Binary files a/vignettes/neon_lma_plsr_example.pdf and b/vignettes/neon_lma_plsr_example.pdf differ diff --git a/vignettes/reseco_leafN_bootstrap_plsr_example.Rmd b/vignettes/reseco_leafN_bootstrap_plsr_example.Rmd index 92f7d69..89af664 100644 --- a/vignettes/reseco_leafN_bootstrap_plsr_example.Rmd +++ b/vignettes/reseco_leafN_bootstrap_plsr_example.Rmd @@ -4,9 +4,9 @@ author: "Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson" output: github_document: default html_notebook: default - pdf_document: default html_document: df_print: paged + pdf_document: default params: date: !r Sys.Date() --- @@ -236,7 +236,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -246,7 +246,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -380,7 +380,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data,intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/reseco_leafN_bootstrap_plsr_example.md b/vignettes/reseco_leafN_bootstrap_plsr_example.md index ccba7eb..8deb809 100644 --- a/vignettes/reseco_leafN_bootstrap_plsr_example.md +++ b/vignettes/reseco_leafN_bootstrap_plsr_example.md @@ -82,7 +82,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpQYfGuz" + ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpmNliia" ### Grab data from EcoSIS @@ -559,7 +559,7 @@ head(cal.plsr.output) ## 6 2.943186 0.656508493 ``` r -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -587,7 +587,7 @@ head(val.plsr.output) ## 189 0.13020008 ``` r -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -788,7 +788,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data,intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) @@ -863,7 +863,7 @@ write.csv(out.jk.coefs,file=file.path(outdir,paste0(inVar, print(paste("Output directory: ", outdir)) ``` - ## [1] "Output directory: /var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T//RtmpQYfGuz" + ## [1] "Output directory: /var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T//RtmpmNliia" ``` r # Observed versus predicted diff --git a/vignettes/reseco_leafN_bootstrap_plsr_example.pdf b/vignettes/reseco_leafN_bootstrap_plsr_example.pdf index 744d157..55d71c5 100644 Binary files a/vignettes/reseco_leafN_bootstrap_plsr_example.pdf and b/vignettes/reseco_leafN_bootstrap_plsr_example.pdf differ diff --git a/vignettes/reseco_leafN_bootstrap_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png b/vignettes/reseco_leafN_bootstrap_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png index 56330cc..1475940 100644 Binary files a/vignettes/reseco_leafN_bootstrap_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png and b/vignettes/reseco_leafN_bootstrap_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png differ diff --git a/vignettes/reseco_leafN_plsr_example.Rmd b/vignettes/reseco_leafN_plsr_example.Rmd index f23800d..a9f27d8 100644 --- a/vignettes/reseco_leafN_plsr_example.Rmd +++ b/vignettes/reseco_leafN_plsr_example.Rmd @@ -2,11 +2,11 @@ title: Spectra-trait PLSR example using leaf-level spectra and leaf nitrogen content (Narea, g/m2) data from 36 species growing in Rosa rugosa invaded coastal grassland communities in Belgium author: "Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson" output: - github_document: default - html_notebook: default pdf_document: default + html_notebook: default html_document: df_print: paged + github_document: default params: date: !r Sys.Date() --- @@ -235,7 +235,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -245,7 +245,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -380,7 +380,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data,intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/reseco_leafN_plsr_example.md b/vignettes/reseco_leafN_plsr_example.md index 88aea0d..f50aa76 100644 --- a/vignettes/reseco_leafN_plsr_example.md +++ b/vignettes/reseco_leafN_plsr_example.md @@ -82,7 +82,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpdoDuGk" + ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpJ6W1sB" ### Grab data from EcoSIS @@ -558,7 +558,7 @@ head(cal.plsr.output) ## 6 2.943186 0.656508493 ``` r -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% "Spectra")], @@ -586,7 +586,7 @@ head(val.plsr.output) ## 189 0.13020008 ``` r -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -798,7 +798,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data,intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) @@ -863,7 +863,7 @@ write.csv(out.jk.coefs,file=file.path(outdir, print(paste("Output directory: ", outdir)) ``` - ## [1] "Output directory: /var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T//RtmpdoDuGk" + ## [1] "Output directory: /var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T//RtmpJ6W1sB" ``` r # Observed versus predicted diff --git a/vignettes/reseco_leafN_plsr_example.pdf b/vignettes/reseco_leafN_plsr_example.pdf index 27623fa..2b2f343 100644 Binary files a/vignettes/reseco_leafN_plsr_example.pdf and b/vignettes/reseco_leafN_plsr_example.pdf differ diff --git a/vignettes/reseco_leafN_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png b/vignettes/reseco_leafN_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png index 56330cc..1475940 100644 Binary files a/vignettes/reseco_leafN_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png and b/vignettes/reseco_leafN_plsr_example_files/figure-gfm/unnamed-chunk-12-1.png differ diff --git a/vignettes/reseco_lma_plsr_example.Rmd b/vignettes/reseco_lma_plsr_example.Rmd index 51d2622..2aa25b9 100644 --- a/vignettes/reseco_lma_plsr_example.Rmd +++ b/vignettes/reseco_lma_plsr_example.Rmd @@ -2,9 +2,9 @@ title: Spectra-trait PLSR example using leaf-level spectra and leaf mass per area (LMA) data from 36 species growing in Rosa rugosa invaded coastal grassland communities in Belgium author: "Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson" output: - github_document: default - html_notebook: default pdf_document: default + html_notebook: default + github_document: default html_document: df_print: paged params: @@ -268,7 +268,7 @@ cal.plsr.output <- data.frame(cal.plsr.data[, which(names(cal.plsr.data) %notin% cal.plsr.output <- cal.plsr.output %>% mutate(PLSR_CV_Residuals = PLSR_CV_Predicted-get(inVar)) head(cal.plsr.output) -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% @@ -280,7 +280,7 @@ val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% val.plsr.output <- val.plsr.output %>% mutate(PLSR_Residuals = PLSR_Predicted-get(inVar)) head(val.plsr.output) -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -429,7 +429,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data,intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) diff --git a/vignettes/reseco_lma_plsr_example.md b/vignettes/reseco_lma_plsr_example.md index 3f95bf0..3015be4 100644 --- a/vignettes/reseco_lma_plsr_example.md +++ b/vignettes/reseco_lma_plsr_example.md @@ -82,7 +82,7 @@ output_dir <- "tempdir" ### Step 3. Set working directory (scratch space) - ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpXi9NpC" + ## [1] "/private/var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T/RtmpoqfeI6" ### Step 4. Pull example dataset from EcoSIS (ecosis.org) @@ -597,7 +597,7 @@ head(cal.plsr.output) ## 6 142.5160 -37.724928 ``` r -cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2) +cal.R2 <- round(pls::R2(plsr.out,intercept=F)[[1]][nComps],2) cal.RMSEP <- round(sqrt(mean(cal.plsr.output$PLSR_CV_Residuals^2)),2) val.plsr.output <- data.frame(val.plsr.data[, which(names(val.plsr.data) %notin% @@ -627,7 +627,7 @@ head(val.plsr.output) ## 189 3.295298 ``` r -val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data)[[1]][nComps],2) +val.R2 <- round(pls::R2(plsr.out,newdata=val.plsr.data,intercept=F)[[1]][nComps],2) val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -826,7 +826,7 @@ rmsep_percrmsep <- spectratrait::percent_rmse(plsr_dataset = val.plsr.output, range="full") RMSEP <- rmsep_percrmsep$rmse perc_RMSEP <- rmsep_percrmsep$perc_rmse -r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data)$val[nComps+1],2) +r2 <- round(pls::R2(plsr.out, newdata = val.plsr.data,intercept=F)$val[nComps],2) expr <- vector("expression", 3) expr[[1]] <- bquote(R^2==.(r2)) expr[[2]] <- bquote(RMSEP==.(round(RMSEP,2))) @@ -897,7 +897,7 @@ write.csv(out.jk.coefs,file=file.path(outdir, print(paste("Output directory: ", outdir)) ``` - ## [1] "Output directory: /var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T//RtmpXi9NpC" + ## [1] "Output directory: /var/folders/xp/h3k9vf3n2jx181ts786_yjrn9c2gjq/T//RtmpoqfeI6" ``` r # Observed versus predicted diff --git a/vignettes/reseco_lma_plsr_example.pdf b/vignettes/reseco_lma_plsr_example.pdf index efb69d3..b600447 100644 Binary files a/vignettes/reseco_lma_plsr_example.pdf and b/vignettes/reseco_lma_plsr_example.pdf differ diff --git a/vignettes/reseco_lma_plsr_example_files/figure-gfm/unnamed-chunk-13-1.png b/vignettes/reseco_lma_plsr_example_files/figure-gfm/unnamed-chunk-13-1.png index 43a32eb..e4d311c 100644 Binary files a/vignettes/reseco_lma_plsr_example_files/figure-gfm/unnamed-chunk-13-1.png and b/vignettes/reseco_lma_plsr_example_files/figure-gfm/unnamed-chunk-13-1.png differ