Extract the fitted linear model for a PrestoGP model
Source:R/PrestoGP_Model.R
get_linear_model-PrestoGPModel-method.Rd
This method return the fitted linear model (of class cv.glmnet) for a PrestoGP model.
Details
It is important to note that the model is fit to the transformed data. The CV error rate and predicted values of Y will not be correct for the original (untransformed) data. This method should be used primarily for examining the coefficient path and generating plots.
References
Messier, K.P. and Katzfuss, M. "Scalable penalized spatiotemporal land-use regression for ground-level nitrogen dioxide", The Annals of Applied Statistics (2021) 15(2):688-710.
Examples
data(soil)
soil <- soil[!is.na(soil[,5]),] # remove rows with NA's
y <- soil[,4] # predict moisture content
X <- as.matrix(soil[,5:9])
locs <- as.matrix(soil[,1:2])
soil.vm <- new("VecchiaModel", n_neighbors = 10)
soil.vm <- prestogp_fit(soil.vm, y, X, locs)
#>
#> Estimating initial beta...
#> Estimation of initial beta complete
#>
#> Beginning iteration 1
#> Estimating theta...
#> Estimation of theta complete
#> Estimating beta...
#> Estimation of beta complete
#> Iteration 1 complete
#> Current penalized negative log likelihood: 487.406
#> Current MSE: 9.104869
#> Beginning iteration 2
#> Estimating theta...
#> Estimation of theta complete
#> Estimating beta...
#> Estimation of beta complete
#> Iteration 2 complete
#> Current penalized negative log likelihood: 487.327
#> Current MSE: 9.107651
#> Beginning iteration 3
#> Estimating theta...
#> Estimation of theta complete
#> Estimating beta...
#> Estimation of beta complete
#> Iteration 3 complete
#> Current penalized negative log likelihood: 487.327
#> Current MSE: 9.107651
get_linear_model(soil.vm)
#>
#> Call: cv.glmnet(x = as.matrix(model@X_tilde), y = as.matrix(model@y_tilde), nfolds = nfolds, foldid = foldid, parallel = parallel, alpha = model@alpha, family = family)
#>
#> Measure: Mean-Squared Error
#>
#> Lambda Index Measure SE Nonzero
#> min 0.00609 26 0.5031 0.07534 4
#> 1se 0.06238 1 0.5127 0.07052 0