Displaying 2 results from an estimated 2 matches for "pcrmodel".
2011 Apr 14
1
saving a regression model to a file
...ing load(), the loaded "model" is just an object
of class Character. Here is the relevant R code:
#######creating the model#########
data <- read.table("../synthetic_data_4.csv", header=TRUE, sep=",")
data <- data.frame(data)
data$type <- factor(data$type)
pcrmodel <- pcr(formula=count~week+type+total, data=data, x=TRUE, y=TRUE)
#########getting summary of model########
summary(pcrmodel)
Output:
Data: X dimension: 318 4
Y dimension: 318 1
Fit method: svdpc
Number of components considered: 4
TRAINING: % variance explained
1 comps 2 comps 3 co...
2011 Apr 18
2
Predicting with a principal component regression model: "non-conformable arguments" error
...FALSE
and I use the predict() function from the PLS package as in the example
from http://rss.acs.unt.edu/Rdoc/library/pls/html/predict.mvr.html, e.g.
###################################
mydata <- read.csv("mydata.csv", header=TRUE)
mydata <- data.frame(mydata)
pcrmodel <- pcr(response ~ var1+var2+var3, data = mydata[mydata$train,])
predict(pcrmodel, type = "response", newdata = mydata[!mydata$train,])
###################################
the code works, and the model predicts new values for the "response"
variable rows where train=FALSE....