0
   

R; plotting interaction terms between two continuous variables

 
 
Reply Thu 17 Jan, 2013 04:08 pm
Hi - I would like to ask a question:

I fitted a linear model in R. This model has terms that have (p<0.05, i.e. significant). these include interaction terms between two continuous variables. Here is a copy:

rm(list=ls())

library(foreign)

dat <- read.spss("P:\\ FILE.sav",
to.data.frame=T)

plot(dat$"X_",dat$"Y_",
xlim=c(0,180),ylim=c(-300,400),
xlab='X',ylab='Y',
pch=16)

z <- mean(dat$AGE)
my.model <- lm((Y_) ~
I(AGE-z)+
Gender+
X_+
I(AGE-z):X_,
data=dat)

curve(my.model$coef[1]+
my.model$coef[2]*z1+
my.model$coef[3]+
my.model$coef[4]*x+
my.model$coef[14]*z1*x,
add=T,col='darkgreen',lwd=2)



My question is with regards to the graphs of the plotted lines. The lines limits exceed the min and max range of the variables x and y, it even goes below zero and above 400, which is unrealistic for my data. I was wondering if I’m actually doing this correctly. How can I creat a plot that reasonably match my data expectations?


Thanks
Sarah



  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 1,385 • Replies: 0
No top replies

 
 

Related Topics

 
  1. Forums
  2. » R; plotting interaction terms between two continuous variables
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.07 seconds on 11/15/2024 at 05:32:24