dtkaplan / statisticalModeling

Other
11 stars 17 forks source link

Plotting data on gmodel output plots #31

Open julianefry opened 7 years ago

julianefry commented 7 years ago

Hello! I have been unable to create plots similar to those shown under the heading "Graphics of model functions" at https://cran.r-project.org/web/packages/statisticalModeling/vignettes/modeling.html, in which data points are overlayed on the model plots. I get the error: "Error: Continuous value supplied to discrete scale" if I attempt to plot the model results for > 1 predictor variable. Sample code generating the error is below. Thank you! library(tidyverse) library("statisticalModeling", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")

Open data from .csv into a data frame

PTRMSFullNormData<-read_csv("https://dl.dropboxusercontent.com/u/353440/NormalizedPTRMSDataForR_5April2017_trimmed.csv")

Build a base model

r43_augmodel<-lm(m43 ~ b + i + x + OH, data=PTRMSFullNormData)

Take a peak

summary(r43_augmodel) gmodel(r43_augmodel)

Graph model output and include data points on the plot:

(this is the broken part)

gmodel(r43_augmodel, ~b + i + x + OH) + ggplot2::geom_point(data = PTRMSFullNormData, alpha=0.1)