Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to create a vector of x-values in the domain of your plot and predict their corresponding y-values from your model. To do this, you need to inject this vector into a dataframe comprised of variables that match those in your model. You stated that you are OK with keeping the other variables fixed at their mean values, so I have used that approach in my solution. Whether or not the x-values you are predicting are actually <em>legal</em> given the other values in your plot should probably be something you consider when setting this up. </p> <p>Without sample data I can't be sure this will work exactly for you, so I apologize if there are any bugs below, but this should at least illustrate the approach.</p> <pre><code># Setup xmin = 0; xmax=10 # domain of your plot D = my.data plot( D$probCategorySame, D$posttestScore, xlim=c(xmin,xmax) ) lmMultiple &lt;- lm( posttestScore ~ pretestScore + probCategorySame + probDataRelated + practiceAccuracy + practiceNumTrials, data=D ) # create a dummy dataframe where all variables = their mean value for each record # except the variable we want to plot, which will vary incrementally over the # domain of the plot. We need this object to get the predicted values we # want to plot. N=1e4 means = colMeans(D) dummyDF = t(as.data.frame(means)) for(i in 2:N){dummyDF=rbind(dummyDF,means)} # There's probably a more elegant way to do this. xv=seq(xmin,xmax, length.out=N) dummyDF$probCSBinned = xv # if this gives you a warning about "Coercing LHS to list," use bracket syntax: #dummyDF[,k] = xv # where k is the column index of the variable `posttestScore` # Getting and plotting predictions over our dummy data. yv=predict(lmMultiple, newdata=subset(dummyDF, select=c(-posttestScore))) lines(xv, yv) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload