[R] Help with fmodel in statisticalModeling package
p@u|@john@ton @end|ng |rom m@nche@ter@@c@uk
Fri Sep 6 11:57:57 CEST 2019
Anyone able to help me with this.
I'm doing a datacamp course and the effect of adding a "bogus variable" to a linear model.
I make a model and initially fmodel works fine.
When I have a second model which uses this "bogus variable" it complains about the type of this variable.
The code below works fine.
# Add bogus column to CPS85 (don't change)
CPS85$bogus <- rnorm(nrow(CPS85)) > 0
cat ("typeof(CPS88$bogus) is:", typeof(CPS85$bogus), "\n")
# Make the base model
base_model <- lm(wage ~ educ + sector + sex, data = CPS85)
# Make the bogus augmented model
aug_model <- lm(wage ~ educ + sector +sex + bogus, data = CPS85)
# Find the MSE of the base model
mean_base <- mean((CPS85$wage - predict(base_model, newdata = CPS85)) ^ 2)
# Find the MSE of the augmented model
mean_aug <- mean((CPS85$wage - predict(aug_model, newdata = CPS85)) ^ 2)
cat("Mean Square Error of base", mean_base,"\n")
cat("Mean Square Error of aug", mean_aug)
However if I uncomment #print(fmodel((aug_model)))
Error: variable 'bogus' was fitted with type "logical" but type "character" was supplied
Any pointers gratefully accepted
Cheer Paul J
Field Support (Slough House)
University of Manchester
Tel 07826 875504
IOSH Managing Safely
Cert No.: 506572
[[alternative HTML version deleted]]
More information about the R-help