This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n = 1000; | |
| coins = rep(0, n) | |
| for (i in 2:n) { | |
| whatToFlip = seq(from = i, to = n, by = i) | |
| coins[whatToFlip] = coins[whatToFlip] + 1 | |
| } | |
| sqrt(which(!as.logical(coins%%2))) | |
| # [1] 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require(lavaan) | |
| bifactor <- " | |
| general.factor =~ Easy_Reservation + Preferred_Seats + Flight_Options + Ticket_Prices | |
| + Seat_Comfort + Seat_Roominess + Overhead_Storage | |
| + Clean_Aircraft + Courtesy + Friendliness + Helpfulness + Service | |
| ticketing =~ Easy_Reservation + Preferred_Seats + Flight_Options + Ticket_Prices | |
| aircraft =~ Seat_Comfort + Seat_Roominess + Overhead_Storage + Clean_Aircraft | |
| service =~ Courtesy + Friendliness + Helpfulness + Service" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(MASS) | |
| library(ggplot2) | |
| # move n around to alter sample size | |
| # move r around to alter effect size | |
| n = 1000; r = .5 | |
| desiredCovMatrix = matrix(c(1,r,r, 1) ,nrow=2, ncol=2); | |
| count = 1000 # number of replications | |
| out = rep(NA,count) # array to store the results | |
| for (i in 1:count) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| VERSION = 1.3 | |
| require 'net/https' | |
| require 'rubygems' | |
| require 'json' | |
| require 'cgi' | |
| # set to true to force inline links | |
| inline = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| umxSaturated <- function(m1, evaluate = T) { | |
| # Use case | |
| # m1_sat = umxSaturated(m1) | |
| # summary(m1, SaturatedLikelihood=m1_sat$SaturatedLikelihood, IndependenceLikelihood=m1_sat$IndependenceLikelihood) | |
| manifests = m1@manifestVars | |
| nVar = length(manifests) | |
| theData = m1@data@observed | |
| dataMeans = colMeans(theData) | |
| meansLabels = paste("mean", 1:nVar, sep="") | |
| loadingsLabels = paste("F", 1:nVar, "loading", sep="") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setMethod("imxVerifyModel", "MxRAMModel", | |
| function(model) { | |
| if ((length(model$A) == 0) || | |
| (length(model$S) == 0) || | |
| (length(model$F) == 0)) { | |
| msg <- paste("The RAM model", omxQuotes(model@name), | |
| "does not contain any paths.", | |
| " Are you just starting out? you need to add paths like", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (identical(options[["Standard Errors"]], "Yes") && | |
| identical(options[["Calculate Hessian"]], "No")) { | |
| msg <- paste('The "Standard Errors" option is enabled and', | |
| 'the "Calculate Hessian" option is disabled. Generating', | |
| 'standard errors requires the Hessian calculation. Please', | |
| 'disable standard errors or enable the Hessian calculation.\n', | |
| 'You can do this with\n', | |
| 'model <- mxOption(model, "Standard Errors", "No")\n', | |
| 'or\n', | |
| 'model <- mxOption(model, "Calculate Hessian", "Yes")' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| persons = rnorm(100, 20,10) | |
| nYearsToRun = 500 | |
| births = deaths = pop = rep(NA,nYearsToRun) | |
| for (y in 1:nYearsToRun) { | |
| populationSize = length(persons) | |
| persons = persons+1 # age everybody | |
| # death | |
| persons <- persons[persons < rnorm(populationSize, 77, 15)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Above are some results from the a matrix of a | |
| # trivariate cholesky with the above diag cells filled in | |
| A = matrix(nrow = 3, byrow = T, c(.71, -.28, .15, -.28, .61, -.38, .15, -.38, .000001)) | |
| [,1] [,2] [,3] | |
| [1,] 0.71 -0.28 1.5e-01 | |
| [2,] -0.28 0.61 -3.8e-01 | |
| [3,] 0.15 -0.38 1.0e-06 | |
| # Yeah... so that's wrong. that's the lower a matrix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x <- data.frame(matrix(ncol = 2, byrow = T, c( | |
| -0.7, 0.2, | |
| 2.1, 2.7, | |
| 1.7, 2.3, | |
| 1.4, 0.8, | |
| 1.9, 2.0, | |
| 1.8, 1.0, | |
| 0.4, -0.4, | |
| 1.1, 0.3, | |
| 0.9, 0.4, |
OlderNewer