How to plot linear regression with two categorical predictors in R? -


i have data-set looks in short version:

> means_rt  snum    realratio   instratio   rt 3       0           0           358.9782 4       50          30          314.2908 5       30          30          330.7382 6       0           0           335.9542 7       30          50          327.9859 8       50          50          302.7551 9       30          30          326.9188 10      30          30          343.7648 11      0           0           384.5667 12      50          30          319.3677 13      30          50          358.409 14      30          30          300.7474 

where snum participant number, realratio , instrratio categorical variables , rt (reaction time) numericle variable. ran regression model:

fit1 <- lm(formula = rt ~ realratio + instratio + realratio*instratio, data = means_rt) summary(fit1)  call: lm(formula = rt ~ realratio + instratio + realratio * instratio,  data = means_rt)  residuals: min      1q  median      3q     max  -85.206 -22.920  -0.381  21.107 105.713   coefficients:                     estimate std. error t value pr(>|t|)     (intercept)         333.807279   9.019529  37.009   <2e-16 *** realratio             0.726752   0.476883   1.524    0.131     instratio            -0.026615   0.471673  -0.056    0.955     realratio:instratio  -0.004032   0.015138  -0.266    0.791      signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1  residual standard error: 37.48 on 91 degrees of freedom multiple r-squared:  0.06734,   adjusted r-squared:  0.03659  f-statistic:  2.19 on 3 , 91 df,  p-value: 0.0946 

and have tried plot regression failed:

ggplot(means_rt, aes(x= realratio, y=rt,  fill=instratio)) +    geom_bar(binwidth = 1.5, alpha = .5, position = "identity") 

how should plot linear regression 2 categorical predictors: realratio , instratio?


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -