plot_ly_surf: plot_ly_surf: Generate Interactive Plots of Response Surface...

Description Usage Arguments Value Examples

View source: R/plot_ly_surf.R

Description

plot_ly_surf: Generate Interactive Plots of Response Surface Objects

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
plot_ly_surf(
  obj = NULL,
  max_x = NULL,
  min_x = NULL,
  max_y = NULL,
  min_y = NULL,
  inc = NULL,
  x1_lab = NULL,
  x2_lab = NULL,
  y_lab = NULL,
  showscale = FALSE,
  show_princ_axis = FALSE
)

Arguments

obj

object created by resp_surf function

inc

Increments of data to be plotted.

x1_lab

label for x axis (X1)

x2_lab

label for y axis (X2)

y_lab

label for z axis (Y)

showscale

Show a color scale for the outcome variable via a legend.

show_princ_axis

Plot the first and second principle axis

max_x1

max possible value of x1. Defines limits.

min_x1

min possible value of x1. Defines limits.

max_x2

max possible value of x2. Defines limits.

min_x2

max possible value of x2. Defines limits.

Value

Interactive plot of response surface.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Importing for magrittr pipe (%>%)
library(tidyverse)

# Defining Correlation Matrix describing how x1 and x2 are related
# Covarince and variance of x1^2, x2^2, and x1*x2 follow from this matrix
cov_mat<-matrix(c(1, 0,
                  0, 1), byrow = TRUE, 2, 2)

# Defining betas x1, x2, x1^2, x2^2, and x1*x2
beta<-c(0, 0, -.075, -.075, .15)

# Defining sig_hat directly to save time for example
sig_hat <- 0.9549575  

# Generating data frame for response suface examining leaders and follower agreeableness
simmed_df<-gen_response_surf_x(1000, cov_mat, x_names = c("L_Agree", "F_Agree"))%>%
  gen_response_surf_y(beta = beta, sigma = sig_hat, y_name = "Satisfaction")

# Fitting a Response Surface Model

model_1<-resp_surf(dep_var = "Satisfaction", 
                   fit_var = c("L_Agree", "F_Agree"), 
                   data = simmed_df, 
                   robust = FALSE)

# Plotting Response Surface Model 

plot_ly_surf(obj = model_1, 
             max_x = 2, 
             min_x = -2,
             max_y =  2, 
             min_y = -2, 
             inc = .1, 
             x1_lab = "Leader Agreeableness", 
             x2_lab = "Follower Agreeableness", 
             y_lab = "Employee Satisfaction", 
             showscale = TRUE)

jimmyrigby94/rrs documentation built on May 12, 2020, 3:41 p.m.