3d Plot
data <- read.csv("data_temp.csv")
summary(data)
## LC_mean Autonomy_mean Meaning_mean LCxAuto
## Min. :1.143 Min. :1.000 Min. :1.000 Min. : 1.143
## 1st Qu.:3.857 1st Qu.:4.000 1st Qu.:4.000 1st Qu.:16.095
## Median :4.571 Median :5.000 Median :4.833 Median :21.429
## Mean :4.425 Mean :4.651 Mean :4.581 Mean :21.068
## 3rd Qu.:5.000 3rd Qu.:5.333 3rd Qu.:5.167 3rd Qu.:25.714
## Max. :6.000 Max. :6.000 Max. :6.000 Max. :36.000
#meaning = LC X1 + Autonomy X2 + LX*Auto + e
m1 <- lm(Meaning_mean ~ LC_mean + Autonomy_mean + LC_mean * Autonomy_mean,
data = data)
m1
##
## Call:
## lm(formula = Meaning_mean ~ LC_mean + Autonomy_mean + LC_mean *
## Autonomy_mean, data = data)
##
## Coefficients:
## (Intercept) LC_mean Autonomy_mean
## -0.32942 0.80634 0.63860
## LC_mean:Autonomy_mean
## -0.07726
summary(m1)
##
## Call:
## lm(formula = Meaning_mean ~ LC_mean + Autonomy_mean + LC_mean *
## Autonomy_mean, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.3631 -0.4434 0.0961 0.5577 2.3189
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.32942 0.60689 -0.543 0.5875
## LC_mean 0.80634 0.15570 5.179 3.38e-07 ***
## Autonomy_mean 0.63860 0.13931 4.584 5.92e-06 ***
## LC_mean:Autonomy_mean -0.07726 0.03286 -2.351 0.0192 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.773 on 449 degrees of freedom
## Multiple R-squared: 0.4147, Adjusted R-squared: 0.4108
## F-statistic: 106.1 on 3 and 449 DF, p-value: < 2.2e-16
require(plotly)
## Loading required package: plotly
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
require(magrittr)
## Loading required package: magrittr
plot_ly(data = data) %>%
add_trace(x = ~LC_mean,
y = ~Autonomy_mean,
z = ~Meaning_mean,
mode = "markers",
type = "scatter3d",
marker = list(size = 5, color = "blue", symbol = 104),
name = "Observations") %>%
add_trace(z = m1$fitted.values,
x = ~LC_mean,
y = ~Autonomy_mean,
type = "mesh3d",
name = "Fitted values") %>%
layout(scene = list(xaxis = list(title = 'LC_mean'),
yaxis = list(title = 'Autonomy_mean'),
camera = list(eye = list(x = -0.5, y = 2, z = 0)),
zaxis = list(title = 'Meaning_mean'),
aspectmode='cube'))