Description Usage Arguments Details Value Author(s) References Examples
Estimates a p2 model using the Laplace approximation.
1 2 3 |
y |
An adjacency matrix of size g x g. |
XnS |
Matrix of sender effects of size g x ks. |
XnR |
Matrix of receiver effects of size g x kr. |
XvD |
Density effects, a 3-dim array of size g x g x kd. |
XvC |
Reciprocity effects, a 3-dim array of size g x g x kc. |
M |
Number of replication for TMB-based importance sampling. Default is 0, giving the Laplace approximation (strongly recommended). |
seed |
Random seed for importance sampling. Default is NULL. |
trace |
TRUE for tracing information during the estimation. Default is FALSE. |
init |
Optional starting value for model parameters. Default is NULL. |
penalized |
Set TRUE for penalized estimation of variance parameters. Default is FALSE. |
penSigma |
Optional variance matrix of random effects to be used as user-defined penalty in penalized estimation. Default is NULL. |
opt |
Name of the optimising function. Default is nlminb. |
singular.ok |
Should singular variance matrix of random effects be allowed? Default is TRUE. |
... |
Optional arguments passed to the optimiser. |
The function allows for penalized estimation, which may be recommendable
to prevent numerical issues, such as estimated variance matrix of random effects
close to singularity. The fit is carried out by means of the TMB package,
and by selecting M>0 it would be possible to employ the importance sampler
made available by that package. However, the function fitIS
provides
a safer alternative for estimation based on importance sampling.
The returned value is an object of class
"p2"
, a list containing the following components:
|
the vector of model estimates. |
|
the log likelihood function at the estimate. |
|
model selection criteria at the estimate. |
|
logical, flagging whether there are no sender or receiver effects, respectively. |
|
the random seed used for estimation (when |
|
Variance matrix of estimates. |
|
Standard errors of estimates. |
|
Optimiser employed for estimation. |
|
Object returned by the optimiser. |
|
Object returned by |
|
List containing all the model data, fed
to |
|
Summary object returned by |
|
Estimated random effects and their standard errors. |
|
Estimated variance matrix of random effects and related standard errors. |
|
Estimated correlation of random effects and its standard error. |
|
Number of importance sampling replications. |
|
Arguments for penalized estimation. |
Ruggero Bellio
Bellio, R. and Soriani, N. (2019). Maximum likelihood estimation based on the Laplace approximation for p2 network regression models. Submitted manuscript.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Analysis of the kracknets data from the NetData package
library(NetData)
data(kracknets)
# data preparation
g <- 21
Y <- matrix(0, g, g)
ind <-1
for(i in 1:nrow(friendship_data_frame)){
sele <- friendship_data_frame[i, ]
Y[sele$ego, sele$alter] <- sele$friendship_tie
}
Xn <- model.matrix(~ AGE + TENURE, attributes)[, -1]
XvD <- array(1, dim=c(g, g, 4))
for(i in 1:g)
for(j in 1:g){
XvD[i, j, 2] <- as.numeric(attributes$DEPT[i]==attributes$DEPT[j])
XvD[i, j, 3] <- as.numeric(attributes$LEVEL[i]==attributes$LEVEL[j])
XvD[i, j, 4] <- abs(attributes$AGE[i] - attributes$AGE[j])
}
XvC <- array(1, dim=c(g, g, 1))
# Now we are ready to fit the model
mod <- fit_p2(Y, Xn, Xn, XvD, XvC)
print(mod)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.