predict

effect vs. predict function

跟風遠走 提交于 2021-02-07 17:32:48
问题 I'm simultaneously trying to understand R's predict() function and the 'effects' package effect() function. Essentially, I'm running a regression to test the interaction of two dichotomous IVs on a DV while controlling for two continuous covariates. In my actual dataset, the interaction is significant and so now I would like to plot the interaction. Because I have covariates in my model, I should plot the means after controlling for these other variables (i.e. estimated marginal means in SPSS

R - Extract ns spline object from lmer model and predict on new data

纵然是瞬间 提交于 2021-02-07 10:31:19
问题 I'm looking to predict 'terms', especially ns splines, from an lmer model. I've replicated the problem with the mtcars dataset (technically poor example, but works to get the point across). Here is what I'm trying to do with a linear model: data(mtcars) mtcarsmodel <- lm(wt ~ ns(drat,2) + hp + as.factor(gear), data= mtcars) summary(mtcarsmodel) coef(mtcarsmodel) test <- predict(mtcarsmodel, type = "terms") Perfect. However, there is no equivalent 'terms' option for lmer predict (unresolved

R - Extract ns spline object from lmer model and predict on new data

馋奶兔 提交于 2021-02-07 10:31:04
问题 I'm looking to predict 'terms', especially ns splines, from an lmer model. I've replicated the problem with the mtcars dataset (technically poor example, but works to get the point across). Here is what I'm trying to do with a linear model: data(mtcars) mtcarsmodel <- lm(wt ~ ns(drat,2) + hp + as.factor(gear), data= mtcars) summary(mtcarsmodel) coef(mtcarsmodel) test <- predict(mtcarsmodel, type = "terms") Perfect. However, there is no equivalent 'terms' option for lmer predict (unresolved

How to calculate 95% prediction interval from nls

蓝咒 提交于 2021-02-07 09:02:33
问题 Borrowing the example data from this question, if I have the following data and I fit the following non linear model to it, how can I calculate the 95% prediction interval for my curve? library(broom) library(tidyverse) x <- seq(0, 4, 0.1) y1 <- (x * 2 / (0.2 + x)) y <- y1 + rnorm(length(y1), 0, 0.2) d <- data.frame(x, y) mymodel <- nls(y ~ v * x / (k + x), start = list(v = 1.9, k = 0.19), data = d) mymodel_aug <- augment(mymodel) ggplot(mymodel_aug, aes(x, y)) + geom_point() + geom_line(aes

Where to place 'input.json file' when do Google Cloud Machine Learning engine prediction?

人盡茶涼 提交于 2021-01-29 22:33:50
问题 I am using Google Cloud ML Engine to do local prediction by run: gcloud ml-engine local predict --model-dir=$MODEL_DIR --json-instances $INPUT_FILE --framework $FRAMEWORK assume: MODEL_DIR="gs://<bucket>/model.joblib" FRAMEWORK="SCIKIT_LEARN" input file input.json is in hardisk (d:\predict) How to specify: INPUT_FILE= ? I have manually upload the input file into my gc bucket, but get error: ERROR: (gcloud.ml-engine.local.predict) Unable to read file [gs://<bucket>/input.json]: [Errno 2] No

Problems with using plotCalibration() from the predictABEL package in R

烈酒焚心 提交于 2021-01-28 06:33:15
问题 I’ve been having some trouble with the plotCalibration() function, I have managed to get it to work before, but recently whilst working with another dataset (here is a link to the .Rda data file), I have been unable to shake off an error message which keeps cropping up: > plotCalibration(data = data, cOutcome = 2, predRisk = data$sortmort) Error in plotCalibration(data = data, cOutcome = 2, predRisk = data$sortmort) : The specified outcome is not a binary variable.` When I’ve tried to set the

Predicting to raster stack at population level with glmmTMB in R

风流意气都作罢 提交于 2021-01-28 06:23:29
问题 I'm trying to predict to a raster stack in R, using a GLMM I fit with the glmmTMB package, at the population level (i.e. setting random effects to 0). I followed Ben Bolker's solution in this thread which works for models fit with lme4 , but even though the function argument re.form=~0 appears to be applicable to predict.glmmTMB in addition to predict.merMod , it's not working for me when I predict using a glmmTMB model. Here is an example using the same example code provided by Robert

Getting different results from Keras model.evaluate and model.predict

安稳与你 提交于 2021-01-23 05:07:23
问题 I have trained a model to predict topic categories using word2vec and an lstm model using keras and got about 98% accuracy during training, I saved the model then loaded it into another file for trying on the test set, I used model.evaluate and model.predict and the results were very different. I'm using keras with tensorflow as a backend, the model summary is: _________________________________________________________________ Layer (type) Output Shape Param # =================================

Getting different results from Keras model.evaluate and model.predict

橙三吉。 提交于 2021-01-23 05:01:24
问题 I have trained a model to predict topic categories using word2vec and an lstm model using keras and got about 98% accuracy during training, I saved the model then loaded it into another file for trying on the test set, I used model.evaluate and model.predict and the results were very different. I'm using keras with tensorflow as a backend, the model summary is: _________________________________________________________________ Layer (type) Output Shape Param # =================================

Adding confidence intervals from model predictions in mixed models in R — ggplot2?

落爺英雄遲暮 提交于 2021-01-07 03:15:16
问题 I have model prediction for mean ans confidence intervals from my data that I want to add on the graph. I know how to plot the data, but how can I add the model fitted mean and confidence intervals? For the latter geom_ribbon does not seem to do the job. df <- data.frame( fertilizer = c("N","N","N","N","N","N","N","N","N","N","N","N","P","P","P","P","P","P","P","P","P","P","P","P","N","N","N","N","N","N","N","N","N","N","N","N","P","P","P","P","P","P","P","P","P","P","P","P"), level = c("low"