Description Usage Arguments Author(s) Examples
View source: R/plot_effects_individual.R
plot_effects_individual
1 2 | plot_effects_individual(data, pred_name, resp_name, predict_funct,
col.by = NULL, npoints = 10, center_effs = TRUE)
|
data |
a data.frame |
pred_name |
character. name of the predictor (x) |
resp_name |
character. name of the response (y) |
predict_funct |
a function that makes predictions |
col.by |
NULL or a vector of values that indicate the strata |
npoints |
10 |
center_effs |
logical. Should be the effect of the oder predictors removed from the lines and the observations? |
livio finos
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | n=100
X=matrix(rnorm(n*3),n,3)
X[,2]=sign(X[,2])
y=rnorm(n,X[,1]+X[,1]*X[,2])
D=data.frame(X)
D$y=y
# Regression model
mod=lm(y~X1*X2+X3,data=D)
summary(mod)
predict_funct=function(newdata) predict(mod,newdata=newdata)
plot_effects_individual(D,"X1","y",predict_funct=predict_funct)
plot_effects_individual(D,"X1","y",predict_funct=predict_funct,col.by = D$X2)
plot_effects_individual(D,"X3","y",predict_funct=predict_funct,center_effs = TRUE)
plot_effects_individual(D,"X3","y",predict_funct=predict_funct,center_effs = FALSE)
# Regression tree model
## Not run:
require(rpart)
mod=rpart(y~X1+X2+X3,data=D,control = list(cp=.0001))
print(mod)
printcp(mod)
predict_funct=function(newdata) predict(mod,newdata=newdata)
#plot_effects_individual(D,"X1","y",predict_funct=predict_funct)
plot_effects_individual(D,"X1","y",predict_funct=predict_funct,col.by = D$X2)
# compare the two:
plot_effects_individual(D,"X3","y",predict_funct=predict_funct,center_effs = TRUE)
plot_effects_individual(D,"X3","y",predict_funct=predict_funct,center_effs = FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.