File: factanal.R

package info (click to toggle)
r-cran-semplot 1.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 464 kB
  • sloc: makefile: 2
file content (44 lines) | stat: -rw-r--r-- 837 bytes parent folder | download | duplicates (4)
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
# semPaths.factanal <- function(object,...) 
# {
#   invisible(semPaths(semPlotModel(object),...))
# }
# 


### SINGLE GROUP MODEL ###
semPlotModel.factanal <- function(object, ...)
{
  
  # Check if object is of class "sem":
  if (!"factanal"%in%class(object)) stop("Input must be a 'factanal' object")
  
  
  # Extract model:
  mod <- semPlotModel(loadings(object))
  manNames <- mod@Vars$name[mod@Vars$manifest]
  
  # Fix:
  mod@Pars$edge <- "->"
  
  # Add residuals:
  Uniqueness <- object$uniquenesses
  
  residPars  <- data.frame(
    label = "", 
    lhs = manNames,
    edge = "<->",
    rhs = manNames,
    est = Uniqueness,
    std = Uniqueness,
    group = "",
    fixed = FALSE,
    par = 0,
    stringsAsFactors=FALSE)
  
  mod@Pars <- rbind(mod@Pars,residPars)
  mod@Pars$par <- 1:nrow(mod@Pars)
  
  
  return(mod)
}