Title: | Parameter Estimation for the Averaging Model of Information Integration Theory |
---|---|
Description: | Implementation of the R-Average method for parameter estimation of averaging models of the Anderson's Information Integration Theory by Vidotto, G., Massidda, D., & Noventa, S. (2010) <https://www.uv.es/psicologica/articulos3FM.10/3Vidotto.pdf>. |
Authors: | Giulio Vidotto <[email protected]>, Stefano Noventa <[email protected]>, Davide Massidda <[email protected]>, Marco Vicentini <[email protected]> |
Maintainer: | Davide Massidda <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.5-8 |
Built: | 2024-11-26 05:37:19 UTC |
Source: | https://github.com/cran/rAverage |
Functions to extract or recalculate the Akaike Information Criterion and the Bayesian Information
Criterion of an averaging model fitted by the rav
function.
AIC(object, ..., k = 2) BIC(object, ...)
AIC(object, ..., k = 2) BIC(object, ...)
object |
An object of class |
... |
Optionally more fitted model objects (see details). |
k |
Numeric, the penalty per parameter to be used; the default k = 2 is the classical AIC. |
The functions AIC and BIC are used, respectively, to extract the Akaike Information Criterion and the
Bayesian Information Criterion of a model fitted by the function rav
.
AIC is calculated as:
where is the number of data available,
is the penalty per parameter ()usually equal to 2),
is the number of parameters and
is the residual sum of squares.
BIC is calculated as:
As default, when , AIC and BIC are corrected in AICc and BICc:
to avoid the correction, set correct = FALSE
. On the contrary, if you want the correction, set
correct = TRUE
. When the argument correct
is not specified, the rule is
applied.
As default, the functions extract the indices of the (first) best model. The optional argument
whichModel
can be specified to extract the indices of another model. Options are:
"null"
: null model
"ESM"
: equal scale values model
"SAM"
: simple averaging model
"EAM"
: equal-weights averaging model
"DAM"
: differential-weight averaging model
"IC"
: information criteria model
A numeric value representing the information criterion of the selected model.
rav
,
rAverage-package
AIC
,
BIC
## Not run: data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) AIC(fm1) BIC(fm1) ## End(Not run)
## Not run: data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) AIC(fm1) BIC(fm1) ## End(Not run)
Function to extract fit model coefficients from an object returned by rav
.
coef(object, ...)
coef(object, ...)
object |
An object of class |
... |
Optionally more fitted model objects. |
Returns the parameters of an averaging model fitted by the rav
function, in the order:
s0
, w0
, s(k,j)
, and w(k,j)
.
As default, the function extract the cofficients of the (first) best model. The optional argument
whichModel
can be specified to extract the values of another model. Options are:
"null"
: null model
"ESM"
: equal scale values model
"SAM"
: simple averaging model
"EAM"
: equal-weights averaging model
"DAM"
: differential-weight averaging model
"IC"
: information criteria model
A numeric vector.
## Not run: data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) coef(fm1) coef(fm1, whichModel="EAM") ## End(Not run)
## Not run: data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) coef(fm1) coef(fm1, whichModel="EAM") ## End(Not run)
This function generates noisy synthetic responses R
for an averaging model given
the true parameters s0
, w0
, s(k,j)
, and w(k,j)
.
datgen(param, lev, t.par = FALSE, trials = 1, sd = 0, range = NULL)
datgen(param, lev, t.par = FALSE, trials = 1, sd = 0, range = NULL)
param |
Numerical vector containing the true parameters for the function, with
the order |
lev |
Vector containing the number of levels of each factor. For instance, two
factors with respectively 3 and 4 levels require |
t.par |
Attribute that specifies whether the weight parameters should be written in the 't' form or in the 'w' form. |
trials |
Number of rows of the output matrix. |
sd |
Standard deviation of the noise addded to the responses R whithin each column of the output matrix. |
range |
Numeric vector. Range of the responses. |
A matrix
object containing the generated responses of the averaging model, in the order:
one-way design, two-way design, three way design, etc. See rav
function.
rav
,
pargen
,
rav.indices
,
rAverage-package
## Not run: # Generating random parameters for a 3x4 design: par <- pargen(lev = c(3,4), s.range = c(0,20)) # Computing the responses: R <- datgen(param=par, lev=c(3,4), sd=0) ; R R <- datgen(param=par, lev=c(3,4), sd=1, trials=10, range=c(0,20)) ; R ## End(Not run)
## Not run: # Generating random parameters for a 3x4 design: par <- pargen(lev = c(3,4), s.range = c(0,20)) # Computing the responses: R <- datgen(param=par, lev=c(3,4), sd=0) ; R R <- datgen(param=par, lev=c(3,4), sd=1, trials=10, range=c(0,20)) ; R ## End(Not run)
Function to extract fitted values from an object returned by rav
.
fitted(object, ...)
fitted(object, ...)
object |
An object of class |
... |
Optionally more fitted model objects. |
Returns the expected responses given an averaging model fitted by the rav
function.
As default, the function extract the fitted values of the (first) best model. The optional
argument whichModel
can be specified to extract the values of another model. Options are:
"null"
: null model
"ESM"
: equal scale values model
"SAM"
: simple averaging model
"EAM"
: equal-weights averaging model
"DAM"
: differential-weight averaging model
"IC"
: information criteria model
A matrix of numeric values.
## Not run: library(rAverage) data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) fitted(fm1) fitted(fm1, whichModel="EAM") ## End(Not run)
## Not run: library(rAverage) data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) fitted(fm1) fitted(fm1, whichModel="EAM") ## End(Not run)
Examples of dataset for R-Average analysis.
fmdata1: example of a 3x3 design. Original parameters:
s0 = 0.0 | w0 = 0.0 |
sA = 12.9 1.5 18.3 | wA = 1.4 0.3 0.5 |
sB = 5.2 5.0 2.3 | wB = 1.6 1.7 1.7 |
fmdata2: example of a 3x5 design. Original parameters:
s0 = 0.0 | w0 = 0.0 |
sA = 19.5 15.2 1.9 | wA = 0.9 1.2 0.6 |
sB = 2.0 4.4 16.1 6.1 6.0 | wB = 1.1 1.0 1.7 0.6 1.3 |
fmdata3: example of a 3x2x3 design. Original parameters:
s0 = 0.0 | w0 = 0.0 |
sA = 5.9 5.2 9.8 | wA = 0.9 1.1 2.2 |
sB = 14.5 2.0 | wB = 0.5 1.9 |
sC = 8.5 1.5 10.7 | wC = 0.6 0.7 1.4 |
data(fmdata1) data(fmdata2) data(fmdata3)
data(fmdata1) data(fmdata2) data(fmdata3)
A matrix
object.
## Not run: data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) data(fmdata2) fm2 <- rav(fmdata2, lev=c(3,5)) data(fmdata3) fm3 <- rav(fmdata3, lev=c(3,2,3)) ## End(Not run)
## Not run: data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) data(fmdata2) fm2 <- rav(fmdata2, lev=c(3,5)) data(fmdata3) fm3 <- rav(fmdata3, lev=c(3,2,3)) ## End(Not run)
Starting by a previously estimated averaging model, this function detect outliers according to a Bonferroni method. The outliers can be substituted with a user-defined value.
outlier.replace(object, whichModel = NULL, alpha = 0.05, value = NA)
outlier.replace(object, whichModel = NULL, alpha = 0.05, value = NA)
object |
An object of class |
whichModel |
Argument that specifies which of the predicted models has to be compared to the observed data. Options are:
As default setting, the (first) best model is used. |
alpha |
Critical value for the z-test on residuals. |
value |
Argument that can be used to set a replacement for the outliers. If a function is specified, it is applied to each column of the final matrix: the resulting value is used to replace outliers detected on the same column. |
A data object in which outliers have been removed or replaced.
data(pasta) model <- rav(pasta, subset="s04", lev=c(3,3), names=c("Price","Packaging")) outlier.replace(model, value=mean) outlier.replace(model, whichModel="IC", value=NA)
data(pasta) model <- rav(pasta, subset="s04", lev=c(3,3), names=c("Price","Packaging")) outlier.replace(model, value=mean) outlier.replace(model, whichModel="IC", value=NA)
Generates a random set of parameters that follows an averaging rule.
pargen(lev, s.range = c(0,20), w.range = exp(c(-5,5)), I0 = FALSE, t.par = FALSE, digits = 2)
pargen(lev, s.range = c(0,20), w.range = exp(c(-5,5)), I0 = FALSE, t.par = FALSE, digits = 2)
lev |
Numeric vector. Number of levels of each factor. |
s.range |
Numeric vector. Range of variability of the s-parameters. |
w.range |
Numeric vector. Range of variability of the w-parameters. |
I0 |
Logical. If set to |
t.par |
Specifies if the weight parameters should be the 't' instead the 'w'. |
digits |
Numeric. Decimal rounding of the parameters. |
Vector contaning the random-generated parameters in the order s0,w0,s(k,i),w(k,i)
.
datgen
,
rav
,
rav.indices
,
rAverage-package
# Generating random parameters for a 3x4 design: param <- pargen(lev = c(3,4))
# Generating random parameters for a 3x4 design: param <- pargen(lev = c(3,4))
Data of four subjects from the Pasta experiment. The table contains data of the one-way sub-designs, folowed by the data of the full-factorial design. Factors: Price (3 levels: 0.89, 0.99, 1.09) and Packaging (3 levels: box with window, box without window, plastic bag).
data(pasta)
data(pasta)
A data.frame
object.
Massidda D., Polezzi D., Vidotto G. (2011). A Functional Measurement approach to cope the non-linearity of judgments in marketing research. Proceedings of the 10th European Conference on Research Methodology for Business and Management Studies. Normandy Business School, Caen, France, 348-354.
data(pasta)
data(pasta)
rav
(R-Average for AVeraging models) is a procedure for estimating
the parameters of the averaging models of Information Integration Theory (Anderson, 1981).
It provides reliable estimations of weights and scale values for a factorial experimental
design (with any number of factors and levels) by selecting the most suitable subset of
the parameters, according to the overall goodness of fit indices and to the complexity
of the design.
rav( data, subset = NULL, mean = FALSE, lev, s.range = c(NA,NA), w.range = exp(c(-5,5)), I0 = FALSE, par.fixed = NULL, all = FALSE, IC.diff = c(2,2), Dt = 0.1, IC.break = FALSE, t.par = FALSE, verbose = FALSE, title = NULL, names = NULL, method = "BFGS", start = c(s=NA,w=exp(0)), lower = NULL, upper = NULL, control = list() )
rav( data, subset = NULL, mean = FALSE, lev, s.range = c(NA,NA), w.range = exp(c(-5,5)), I0 = FALSE, par.fixed = NULL, all = FALSE, IC.diff = c(2,2), Dt = 0.1, IC.break = FALSE, t.par = FALSE, verbose = FALSE, title = NULL, names = NULL, method = "BFGS", start = c(s=NA,w=exp(0)), lower = NULL, upper = NULL, control = list() )
data |
An object of type |
subset |
Character, numeric or factor attribute that selects a subset of experimental data for the analysis (see the examples). |
mean |
Logical value wich specifies if the analysis must be performed on raw data ( |
lev |
Vector containing the number of levels of each factor. For instance, two factors
with respectively 3 and 4 levels require |
s.range , w.range
|
The range of s and w parameters. Each vector must contains, respectively, the minimum and the
maximum value. For s-parameters, if the default value |
I0 |
Logical. If set |
par.fixed |
This argument allows to constrain one or more parameters to a specified value. Default
setting to |
all |
Logical. If set |
IC.diff |
Vector containing the cut-off values (of both BIC and AIC indices) at which different
models are considered equivalent. Default setting: BIC difference = 2.0, AIC difference = 2.0
( |
Dt |
Numeric attribute that set the cut-off value at which different t-parameters must be considered equal (see details). |
IC.break |
Logical argument which specifies if to run the Information Criteria Procedure. |
t.par |
Logical. Specifies if the output must shows the t-parameters instead of the w-parameters. |
verbose |
Logical. If set |
title |
Character. Label to use as title for output. |
names |
Vector of character strings containing the names of the factors. |
method |
The minimization algorithm that has to be used. Options are: "L-BFGS-B", "BFGS", "Nelder-Mead",
"SANN" and "CG". See |
start |
Vector containing the starting values for respectively scale and weight parameters. For the scale
parameters, if the default value |
lower |
Vector containing the lower values for scale and weight parameters when the minimization
routine is L-BFGS-B. With the default setting |
upper |
Vector containing the upper values for scale and weight parameters when the minimization
routine is L-BFGS-B. With the default setting |
control |
A list of control parameters. See the |
The rav
function implements the R-Average method (Vidotto & Vicentini, 2007; Vidotto,
Massidda & Noventa, 2010), for the parameter estimation of averaging models. R-Average consists
of several procedures which compute different models with a progressive increasing degree of complexity:
Null Model (null): identifies a single scale value for all the levels of all factors. It assumes constant weights.
Equal scale values model (ESM): makes a distinction between the scale values of different factors, estimating a single s-parameter for each factor. It assumes constant weights.
Simple averaging model (SAM): estimates different scale values between factors and within the levels of each factor. It assumes constant weights.
Equal-weight averaging model (EAM): differentiates the weighs between factors, but not within the levels of each factor.
Differential-weight averaging model (DAM): differentiates the weighs both between factors and within the levels of each factor.
Information criteria (IC): the IC procedure starts from the EAM and, step by step, it frees different combinations of weights, checking whether a new estimated model is better than the previous baseline. The Occam razor, applied by means of the Akaike and Bayesian information criteria, is used in order to find a compromise between explanation and parsimony.
Finally, only the best model is shown.
The R-Average procedures estimates both scale values and weight parameters by minimizing the residual sum of
squares of the model. The objective function is then the square of the distance between theoretical responses
and observed responses (Residual Sum of Squares). For a design with factors with
levels,
theoretical responses are defined as:
where any weight parameter is defined as:
Optimization is performed on -values, and weights are the exponential transformation of
. See Vidotto (2011) for details.
An object of class "rav"
. The method summary
applied to the rav
object prints all the fitted models. The functions fitted.values
, residuals
and
coefficients
can be used to extract respectively fitted values (predicted responses), the
matrix of residuals and the set of estimated parameters.
Supervisor: Prof. Giulio Vidotto [email protected]
University of Padova, Department of General Psychology
QPLab: Quantitative Psychology Laboratory
version 0.0:
Marco Vicentini [email protected]
version 0.1 and following:
Stefano Noventa [email protected]
Davide Massidda [email protected]
Akaike, H. (1976). Canonical correlation analysis of time series and the use of an information criterion. In: R. K. Mehra & D. G. Lainotis (Eds.), System identification: Advances and case studies (pp. 52-107). New York: Academic Press. doi: 10.1016/S0076-5392(08)60869-3
Anderson, N. H. (1981). Foundations of Information Integration Theory. New York: Academic Press. doi: 10.2307/1422202
Anderson, N. H. (1982). Methods of Information Integration Theory. New York: Academic Press.
Anderson, N. H. (1991). Contributions to information integration theory: volume 1: cognition. Lawrence Erlbaum Associates, Hillsdale, New Jersey. doi: 10.2307/1422884
Anderson, N. H. (2007). Comment on article of Vidotto and Vicentini. Teorie & Modelli, Vol. 12 (1-2), 223-224.
Byrd, R. H., Lu, P., Nocedal, J., & Zhu, C. (1995). A limited memory algorithm for bound constrained optimization. Journal Scientific Computing, 16, 1190-1208. doi: 10.1137/0916069
Kuha, J. (2004). AIC and BIC: Comparisons of Assumptions and Performance. Sociological Methods & Research, 33 (2), 188-229.
Nelder, J. A., & Mead, R. (1965). A Simplex Method for Function Minimization. The Computer Journal, 7, 308-313. doi: 10.1093/comjnl/7.4.308
Vidotto, G., Massidda, D., & Noventa, S. (2010). Averaging models: parameters estimation with the R-Average procedure. Psicologica, 31, 461-475. URL https://www.uv.es/psicologica/articulos3FM.10/3Vidotto.pdf
Vidotto, G. & Vicentini, M. (2007). A general method for parameter estimation of averaging models. Teorie & Modelli, Vol. 12 (1-2), 211-221.
rAverage-package
,
rav.single
,
datgen
,
pargen
,
rav.indices
,
rav2file
,
outlier.replace
,
optim
## Not run: # -------------------------------------- # Example 1: 3x3 factorial design # -------------------------------------- # The first column is filled with a sequence of NA values. data(fmdata1) fmdata1 # For a two factors design, the matrix data contains the one-way # sub-design and the two-ways full factorial design observed data. # Pay attention to the columns order: # sub-design: A1, A2, A3, B1, B2, B3 # full factorial: A1B1, A1B2, A1B3, A2B1, A2B2, A2B3, A3B1, A3B2, A3B3 # Start the R-Average procedure: fm1 <- rav(fmdata1, lev=c(3,3)) # (notice that 'range' argument specifies the range of the response scale) fm1 # print the best model selected summary(fm1) # print the fitted models # To insert the factor names: fact.names <- c("Name of factor A", "Name of factor B") fm1 <- rav(fmdata1, lev=c(3,3), names=fact.names) # To insert a title for the output: fm1 <- rav(fmdata1, lev=c(3,3), title="Put your title here") # To supervise the information criterion work flow: fm1 <- rav(fmdata1, lev=c(3,3), verbose=TRUE) # To increase the number of iterations of the minimization routine: fm1 <- rav(fmdata1, lev=c(3,3), control=list(maxit=5000)) # To change the estimation bounds for the scale parameters: fm1.sMod <- rav(fmdata1, lev=c(3,3), s.range=c(0,20)) # To change the estimation bounds for the weight parameters: fm1.wMod <- rav(fmdata1, lev=c(3,3), w.range=c(0.01,10)) # To set a fixed value for weights: fm1.fix <- rav(fmdata1, lev=c(3,3), par.fixed="w") # rav can work without sub-designs. If any sub-design is not available, # the corresponding column must be coded with NA values. For example: fmdata1[,1:3] <- NA fmdata1 fmdata1 # the A sub-design is empty fm1.bis <- rav(fmdata1, lev=c(3,3), title="Sub-design A is empty") # Using a subset of data: data(pasta) pasta # Analyzing "s04" only: fact.names <- c("Price","Packaging") fm.subj04 <- rav(pasta, subset="s04", lev=c(3,3), names=fact.names) # -------------------------------------- # Example 2: 3x5 factorial design # -------------------------------------- data(fmdata2) fmdata2 # (pay attention to the columns order) fm2 <- rav(fmdata2, lev=c(3,5)) # Removing all the one-way sub-design: fmdata2[,1:8] <- NA fm2.bis <- rav(fmdata2, lev=c(3,5)) # -------------------------------------- # Example 3: 3x2x3 factorial design # -------------------------------------- data(fmdata3) # (pay attention to the columns order) fm3 <- rav(fmdata3, lev=c(3,2,3)) # Removing all the one-way design and the AxC sub-design: fmdata3[,1:8] <- NA # one-way designs fmdata3[,15:23] <- NA # AxC design fm3 <- rav(fmdata3, lev=c(3,2,3)) ## End(Not run)
## Not run: # -------------------------------------- # Example 1: 3x3 factorial design # -------------------------------------- # The first column is filled with a sequence of NA values. data(fmdata1) fmdata1 # For a two factors design, the matrix data contains the one-way # sub-design and the two-ways full factorial design observed data. # Pay attention to the columns order: # sub-design: A1, A2, A3, B1, B2, B3 # full factorial: A1B1, A1B2, A1B3, A2B1, A2B2, A2B3, A3B1, A3B2, A3B3 # Start the R-Average procedure: fm1 <- rav(fmdata1, lev=c(3,3)) # (notice that 'range' argument specifies the range of the response scale) fm1 # print the best model selected summary(fm1) # print the fitted models # To insert the factor names: fact.names <- c("Name of factor A", "Name of factor B") fm1 <- rav(fmdata1, lev=c(3,3), names=fact.names) # To insert a title for the output: fm1 <- rav(fmdata1, lev=c(3,3), title="Put your title here") # To supervise the information criterion work flow: fm1 <- rav(fmdata1, lev=c(3,3), verbose=TRUE) # To increase the number of iterations of the minimization routine: fm1 <- rav(fmdata1, lev=c(3,3), control=list(maxit=5000)) # To change the estimation bounds for the scale parameters: fm1.sMod <- rav(fmdata1, lev=c(3,3), s.range=c(0,20)) # To change the estimation bounds for the weight parameters: fm1.wMod <- rav(fmdata1, lev=c(3,3), w.range=c(0.01,10)) # To set a fixed value for weights: fm1.fix <- rav(fmdata1, lev=c(3,3), par.fixed="w") # rav can work without sub-designs. If any sub-design is not available, # the corresponding column must be coded with NA values. For example: fmdata1[,1:3] <- NA fmdata1 fmdata1 # the A sub-design is empty fm1.bis <- rav(fmdata1, lev=c(3,3), title="Sub-design A is empty") # Using a subset of data: data(pasta) pasta # Analyzing "s04" only: fact.names <- c("Price","Packaging") fm.subj04 <- rav(pasta, subset="s04", lev=c(3,3), names=fact.names) # -------------------------------------- # Example 2: 3x5 factorial design # -------------------------------------- data(fmdata2) fmdata2 # (pay attention to the columns order) fm2 <- rav(fmdata2, lev=c(3,5)) # Removing all the one-way sub-design: fmdata2[,1:8] <- NA fm2.bis <- rav(fmdata2, lev=c(3,5)) # -------------------------------------- # Example 3: 3x2x3 factorial design # -------------------------------------- data(fmdata3) # (pay attention to the columns order) fm3 <- rav(fmdata3, lev=c(3,2,3)) # Removing all the one-way design and the AxC sub-design: fmdata3[,1:8] <- NA # one-way designs fmdata3[,15:23] <- NA # AxC design fm3 <- rav(fmdata3, lev=c(3,2,3)) ## End(Not run)
rav
formatrav.grid
is a function that generates an empty (NA
s filled) dataset according to the 'rAverage' format.
rav.grid(lev, trials = 1, subset = FALSE, names = NULL)
rav.grid(lev, trials = 1, subset = FALSE, names = NULL)
lev |
Vector containing the number of levels of each factor. For instance, two
factors with respectively 3 and 4 levels require |
trials |
Number of rows of the output matrix. |
subset |
Logical. Indicates whether the matrix should contain a first column for subset coding. |
names |
Character. Indicates the column names (optional). |
A data.frame
object.
rav
,
pargen
,
datgen
,
rAverage-package
rav.grid(lev=c(3,2,3), trials=5, names=c("Hk","Fa","Mg"))
rav.grid(lev=c(3,2,3), trials=5, names=c("Hk","Fa","Mg"))
The function fit.indices
returns the fit indices for the averaging model given the parameters
s0
, w0
, s(k,j)
, and w(k,j)
.
rav.indices(param, lev, data, t.par = FALSE, subset = NULL, n.pars = NULL, names = NULL, title = NULL)
rav.indices(param, lev, data, t.par = FALSE, subset = NULL, n.pars = NULL, names = NULL, title = NULL)
param |
Numerical vector containing the parameters for the function, with the order
|
lev |
Vector containing the number of levels of each factor. For instance, two factors with
respectively 3 and 4 levels require |
data |
A |
t.par |
Specifies whether the weight parameters should be the in 't' form or in the 'w' form. |
subset |
Character, numeric or factor attribute that selects a subset of experimental data for the analysis (see the examples). |
n.pars |
Number of parameters of the model. If |
names |
Vector of character strings containing the names of the factors. |
title |
Character specifying a title for the output. |
Returns the main fit indices (AIC, BIC, R-squared, Adjusted R-squared), the estimated parameters, the fitted values and the residuals of an averaging model.
An object of class "indices"
.
## Not run: data(fmdata1) s <- c(12.9, 1.5, 18.3, 5.2, 5.0, 2.3) w <- c(1.4, 0.3, 0.5, 1.6, 1.7, 1.7) param <- c(NA,NA, s, w) # Estimated model by rav: fit1 <- rav(fmdata1, lev=c(3,3)) ; fit1 # Fitted model by original parameters: fit2 <- rav.indices(param=param, lev=c(3,3), data=fmdata1) ; fit2 ## End(Not run)
## Not run: data(fmdata1) s <- c(12.9, 1.5, 18.3, 5.2, 5.0, 2.3) w <- c(1.4, 0.3, 0.5, 1.6, 1.7, 1.7) param <- c(NA,NA, s, w) # Estimated model by rav: fit1 <- rav(fmdata1, lev=c(3,3)) ; fit1 # Fitted model by original parameters: fit2 <- rav.indices(param=param, lev=c(3,3), data=fmdata1) ; fit2 ## End(Not run)
Analyzes averaging models for every single subjects in a data matrix and store the estimated parameters in a list.
rav.single(data,...)
rav.single(data,...)
data |
An object of type |
... |
Further arguments for the |
The rav.single
function is a wrapper for the rav
function. Using rav
,
rav.sigle
analyzes subjects one at time, specifying time by time a different value for
subset
.
A list
object in which each slot contains results of a single subject. The ordering of
the subjects is the same as in the input data matrix.
## Not run: data(pasta) model <- rav.single(pasta,lev=c(3,3)) model$s41 # extracts the subject 's41' ## End(Not run)
## Not run: data(pasta) model <- rav.single(pasta,lev=c(3,3)) model$s41 # extracts the subject 's41' ## End(Not run)
rav
resultsThe function exports to a text file the estimated parameters or the model residuals from a call to rav
.
rav2file(object, what = c("resid","param"), whichModel = NULL, file = file.choose(), sep = ",", dec = ".")
rav2file(object, what = c("resid","param"), whichModel = NULL, file = file.choose(), sep = ",", dec = ".")
object |
An object analyzed by the function |
what |
Character string indicating which output should be stored in the file, if raw residuals
( |
whichModel |
Argument that specifies from which model values must be extracted. Options are:
As default setting, the values of the (first) best model are extracted. |
file |
A character string naming the file to write. As default, the function opens a mask to choose or build a file interactively. |
sep |
Field separator string. Values within each row will be separated by this string. |
dec |
String argument used to specify the decimal separator. |
## Not run: data(pasta) model <- rav.single(pasta,lev=c(3,3)) rav2file(model, what="resid", file="PastaResid-1.csv") rav2file(model, what="resid", file="PastaResid-2.csv", sep=";", dec=",") ## End(Not run)
## Not run: data(pasta) model <- rav.single(pasta,lev=c(3,3)) rav2file(model, what="resid", file="PastaResid-1.csv") rav2file(model, what="resid", file="PastaResid-2.csv", sep=";", dec=",") ## End(Not run)
The R-Average package implements a method to identify the parameters of the Averagingcmodel of Information Integration Theory (Anderson, 1981), following the spirit of the so-called "principle of parsimony".
Name of the parameters:
s0,w0
: initial state values of the Averaging Model.s(k,j)
: scale value of the j
-th level of k
-th factor.w(k,j)
: weight value of the j
-th level of k
-th factor.
Package: | rAverage |
Type: | Package |
Version: | 0.5-8 |
Date: | 2017-07-29 |
License: | GNU (version 2 or later) |
Functions of the R-Average package:
rav
: estimates the parameters for averaging models.fitted
: extracts the predicted values of the best model from a rav
object.residuals
: extracts the residuals from a rav
object.coefficients
: extracts the parameters from a rav
object.outlier.replace
: given an estimated averaging model with the rav
function, it
detects and replace outliers from the residual matrix.
rav.indices
: given a set of parameters s
and w
and a matrix of observed
data, it calculates the fit indices for the averaging model.datgen
: returns the responses R
for averaging models
given the set of parameters s
and w
.pargen
: generates pseudorandom parameters for the averaging model.rav.grid
: generates an empty matrix in 'rav' format.rav.single
: single subjects analysis over an aggregated data matrix.rav2file
: store the reesults of rav
into a text file.
Supervisor: Prof. Giulio Vidotto [email protected]
University of Padova, Department of General Psychology
QPLab: Quantitative Psychology Laboratory
version 0.0:
Marco Vicentini [email protected]
version 0.1 and following:
Stefano Noventa [email protected]
Davide Massidda [email protected]
Akaike, H. (1976). Canonical correlation analysis of time series and the use of an information criterion. In: R. K. Mehra & D. G. Lainotis (Eds.), System identification: Advances and case studies (pp. 52-107). New York: Academic Press. doi: 10.1016/S0076-5392(08)60869-3
Anderson, N. H. (1981). Foundations of Information Integration Theory. New York: Academic Press. doi: 10.2307/1422202
Anderson, N. H. (1982). Methods of Information Integration Theory. New York: Academic Press.
Anderson, N. H. (1991). Contributions to information integration theory: volume 1: cognition. Lawrence Erlbaum Associates, Hillsdale, New Jersey. doi: 10.2307/1422884
Anderson, N. H. (2007). Comment on article of Vidotto and Vicentini. Teorie & Modelli, Vol. 12 (1-2), 223-224.
Byrd, R. H., Lu, P., Nocedal, J., & Zhu, C. (1995). A limited memory algorithm for bound constrained optimization. Journal Scientific Computing, 16, 1190-1208. doi: 10.1137/0916069
Kuha, J. (2004). AIC and BIC: Comparisons of Assumptions and Performance. Sociological Methods & Research, 33 (2), 188-229.
Nelder, J. A., & Mead, R. (1965). A Simplex Method for Function Minimization. The Computer Journal, 7, 308-313. doi: 10.1093/comjnl/7.4.308
Vidotto, G., Massidda, D., & Noventa, S. (2010). Averaging models: parameters estimation with the R-Average procedure. Psicologica, 31, 461-475. URL https://www.uv.es/psicologica/articulos3FM.10/3Vidotto.pdf
Vidotto, G. & Vicentini, M. (2007). A general method for parameter estimation of averaging models. Teorie & Modelli, Vol. 12 (1-2), 211-221.
rav
,
datgen
,
pargen
,
rav.indices
,
fmdata1
,
pasta
,
optim
Function to extract residuals from an object returned by rav
.
residuals(object, ...)
residuals(object, ...)
object |
An object of class |
... |
Optionally more fitted model objects. |
Returns the residuals of an averaging model fitted by the rav
function. When standard
= TRUE
, residuals will be transformed in z-scale (mean=0 and sd=1 in each column).
As default, the function extract the residuals of the (first) best model. The optional argument
whichModel
can be specified to extract the values of another model. Options are:
"null"
: null model
"ESM"
: equal scale values model
"SAM"
: simple averaging model
"EAM"
: equal-weights averaging model
"DAM"
: differential-weight averaging model
"IC"
: information criteria model
A matrix of numeric values.
## Not run: data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) residuals(fm1) residuals(fm1, whichModel="EAM") residuals(fm1, whichModel="EAM", standard=TRUE) ## End(Not run)
## Not run: data(fmdata1) fm1 <- rav(fmdata1, lev=c(3,3)) residuals(fm1) residuals(fm1, whichModel="EAM") residuals(fm1, whichModel="EAM", standard=TRUE) ## End(Not run)