BadLM: BadLM shiny app

Description Usage Arguments Details Value Author(s) Examples

View source: R/BadLM.r

Description

Launches the BadLM shiny app, a tool to explore the consequences of the violation of homoscedasticity and/or normality assumptions in a linear model

Usage

1
BadLM(dist.custom = NULL, dist.custom.veravar = NULL, dist.custom.param = NULL)

Arguments

dist.custom

custom generator for Y, see examples below

dist.custom.veravar

variance function for dist.custom, see examples below

dist.custom.param

parameters for dist.custom, see examples below

Details

Allows to set a data generating mechanism for a response variable Y and an explanatory variable x such that E(Y|X=x)=β_1+β_2 x, various possible distributions for Y are available, depending on the selected distributional assumptions the variance may also be set as a function of x. The program performs a number of simulations from the fit and visualizes the simulated sampling distributions of the estimators.

The user can also decide the distribution of the explanatory variable x: the shape is chosen by the user, then the variable is standardized to have minimum equal to 0 and maximum equal to x^*<1, also chosen by the user (the purpose of this is to explore the out of sample prediction performance of the estimated model). The observations x_1,…,x_n are simulated only once, and kept fixed as appropriate for a regression model which is conditional on the explanatory variable.

Additional data generating mechanisms may be specified by the user and given as an input to the function calling the shiny app (see examples).

Full help is available from within the shiny app.

Value

None

Author(s)

Francesco Pauli, francesco.pauli@deams.units.it

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
## Not run:
if (interactive()){
BadLM()

# function to generate Y
dist=function(n,my,parvet,par,x) {
  my+parvet*rt(n,df=par[1])
}
# function to give the true value of the variance
varfun=function(my,parvet,par,x){
  if (par[1]>2) {
    veravar=parvet^2*par[1]/(par[1]-2)
  } else {
    veravar=-1
  }
  return(veravar)
}
# dist and varfun must have those argument where
#  my is the vector mean of Y
#  parvet is g() computed at x values
#  par is a vector of two parameters
param=list(nome="Student-t (bis)", #name of dist for drop down menu (optional)
           nomepar1="Gradi di libertà", #name of parameter 1 (optional)
           minpar1=1,maxpar1=30, #min/max of param 1 (needed)
           valuepar1=10, #initial value of param1 (optional)
           steppar1=0.1, #increment of param1 (optional)
           enableVarFunPanel=TRUE #whether the panel to input g should appear
)

BadLM(dist.custom=dist,dist.custom.veravar = varfun,dist.custom.param=param)


dist=function(n,my,parvet,par,x) {
 my+rnorm(n,0,sqrt(par[1]+par[2]*x^2))
}
# function to give the true value of the variance
varfun=function(my,parvet,par,x){
 return(par[1]+par[2]*x^2)
}
# dist and varfun must have those argument where
#  my is the vector mean of Y
#  parvet is g() computed at x values
#  par is a vector of two parameters
param=list(nome="N(.,b1+b2*x^2)", #name of dist for drop down menu (optional)
           nomepar1="b1", #name of parameter 1 (optional)
           minpar1=1,maxpar1=3, #min/max of param 1 (needed)
           valuepar1=1, #initial value of param1 (optional)
           steppar1=0.1, #increment of param1 (optional)
           nomepar2="b2", #name of parameter 1 (optional)
           minpar2=0,maxpar2=3, #min/max of param 1 (needed)
           valuepar2=1, #initial value of param1 (optional)
           steppar2=0.1, #increment of param1 (optional)
           enableVarFunPanel=FALSE, #whether the panel to input g should appear
           showVarFun=TRUE
)

  BadLM(dist.custom=dist,dist.custom.veravar = varfun,dist.custom.param=param)
}
## End(Not run)

lmviz documentation built on Aug. 25, 2020, 1:06 a.m.