Displaying 20 results from an estimated 48 matches for "samplesize".
2008 Apr 13
2
Arrays and functions
...a stats project using R to work out the size of a t-test and wilcoxon test depending on the distribution and sample size. I just can't get it to work - I want to put my results from the function size() into an array.At the moment I keep getting the error message:Error in res[distribution, test, samplesize] <- results : subscript out of boundsCan anyone tell me where I'm going wrong, please?!size.power.test<-function(){k<-1000distributions<-c("Normal","Uniform")tests<-c("t","Wilcoxon")samplesizes<-c(10,30,40)res<-array(0,c(length(distri...
2008 Apr 12
0
FW:
...a stats project using R to work out the size of a t-test and wilcoxon test depending on the distribution and sample size. I just can't get it to work - I want to put my results from the function size() into an array.At the moment I keep getting the error message:Error in res[distribution, test, samplesize] <- results : subscript out of boundsCan anyone tell me where I'm going wrong, please?! size.power.test<-function(){k<-1000distributions<-c("Normal","Uniform")tests<-c("t","Wilcoxon")samplesizes<-c(10,30,40)res<-array(0,c(length(distr...
2009 Sep 18
1
lapply - value changes as parameters to function?
Hi,
I'm trying to get better at things like lapply but it still stumps
me. I have a function I've written, tested and debugged using
individual calls to the function, ala:
ResultList5 = DoAvgCalcs(IndexData, Lookback=5,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList8 = DoAvgCalcs(IndexData, Lookback=8,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList13 = DoAvgCalcs(IndexData, Lookback=13,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList21 = DoAvgCalcs(IndexData, Lookback=21,
Sa...
2010 Jul 22
1
How do I get rid of list elements where the value is NULL before applying rbind?
...is the function that makes the data.frames in the list:
funweek <- function(df)
if (length(df$elapsed_time) > 5) {
res = fitdist(df$elapsed_time,"exp")
year = df$sale_year[1]
sample = df$sale_week[1]
mid = df$m_id[1]
estimate = res$estimate
sd = res$sd
samplesize = res$n
loglik = res$loglik
aic = res$aic
bic = res$bic
chisq = res$chisq
chisqpvalue = res$chisqpvalue
chisqdf = res$chisqdf
if (!is.null(estimate) && !is.null(sd) && !is.null(loglik) &&
!is.null(aic) && !is.null(bic) &&
!...
2018 Oct 04
2
Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)
...s?
There might be more to be said, but I thought I'd just add what I could from playing around with it a little bit.
For anyone who wishes to give it a try, I suggest this implementation of the autocorrelation tester which is about 80 times faster:
DistributionAutocorrelation_new <- function(SampleSize)????{
? ? Cor <- replicate(1e5, function() {X <- rnorm(SampleSize)? ? return(cor(X[-1], X[-length(X)]))})? ? return(Cor)}
I have the same Stats package version installed.
- (Thomas) William BellHons BSc Candidate (Biology and Mathematics)BA Candidate (Philosophy)McMaster University
# Hi,#?#?#...
2018 Oct 04
2
Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)
...s?
There might be more to be said, but I thought I'd just add what I could from playing around with it a little bit.
For anyone who wishes to give it a try, I suggest this implementation of the autocorrelation tester which is about 80 times faster:
DistributionAutocorrelation_new <- function(SampleSize)????{
? ? Cor <- replicate(1e5, function() {X <- rnorm(SampleSize)? ? return(cor(X[-1], X[-length(X)]))})? ? return(Cor)}
I have the same Stats package version installed.
- (Thomas) William BellHons BSc Candidate (Biology and Mathematics)BA Candidate (Philosophy)McMaster University
# Hi,#?#?#...
2011 Mar 25
1
Appending data to a data.frame and writing a csv
...0.45,0.45,0.45,0.45))
param <- data.frame(alpha = 0.99, size = 50) # size is basically no of simulations
n <-
length(exposure$id)
id <- exposure$id
ead <- exposure$ead
lgd <- exposure$lgd
pd <- exposure$pd
alpha <- param$alpha
samplesize <- param$size
## generate random numbers s.t. 1 = Default, 0 = no-default.
L <- matrix(data=NA, nrow=n, ncol=samplesize, byrow=TRUE)
for(i in 1:n)
L[i,] <- rbinom(n=samplesize, size=1, prob=exposure$pd[i])
# ________________________________________________________________
# compu...
2001 Dec 09
1
Help for Power analysis
...,correct=F)$statistic
Ntotal<-sum(data1)
df<- ncol(nc-1)*nrow(nr-1)
ifelse(df==1,w<- sqrt(chi2/Ntotal), w<-sqrt(chi2/(chi2+Ntotal)))
Ntotal1<-900 #change this if power not enough
alpha <-0.05 #change this for One tailed =0.05
ncp<-0
chicrit<-NULL
power<-NULL
n<-NULL
samplesize<-NULL
for (i in 1:Ntotal1){
ncp[i] <- w^2 * i
chicrit<-qchisq(1-alpha,df)
power[i] <- 1-(pchisq(chicrit , df, ncp[i]))
n[i]<-i
samplesize<-cbind(n, ncp,power) }
samplesize
plot(n,power,type="l",col="red", lwd=1,
panel.first = grid(10,10),
main=&q...
2009 Jun 07
1
Survreg function for loglogistic hazard estimation
...beta of loglogistic regression. Any comments? Thanks a lot,
Jiakai Chen
Code:
============BEGIN==============
# A time invariant loglogistic estimation
library(survival)
# Clear the workspace
rm(list = ls(all = TRUE))
# Totally 100K samples which may die during 100 periods
timeline = 100
samplesize = 100000
dfico <- rnorm(samplesize, mean = 0, sd = 25)
dficoeff <- 0.005
# Baseline loglogistic hazard function stored in bhaz
a<- 20
b <- 4
time <- 1:timeline
bhaz <- ((b/a) * (time /a) ^ (b-1))/(1+(time/a)^b)
# Event time stored in endtime. Baseline hazard function is contr...
2010 Sep 19
1
Weibull- Random Censoring
I generate random vector from Weibull distribution
sampWB <-urweibull(sampleSize, shape=shape.true, scale=scale.true, lb=0, ub=Inf)
how can I create subvector containing 30% of samplesize of sampWB which should be assigned as Censored data?
The probability for each value in sampWB can be uniform to be included in the subvector.
2010 Aug 11
1
sem & psych
...lt;- c(0.3, 0.5, 0.7) # loads of observed variables on trait
factors
traitCorrs <- c(0.0, 0.4, 0.7) # correlations between traits
methodLoads <- c(0.2, 0.3, 0.4) # loads of observed variables on method
factors
methdCorrs <- c(0.0, 0.2, 0.4) # correlations between methods
SampleSize <- 500 # Sample size
myMaxIter <- 500 # Maximal number of interactions in
every model estimation
nCond <- length(traitLoads)* length(traitCorrs)* length(methodLoads)*
length(methdCorrs)
myRes <- as.numeric(gl(nCond, 1, myRep*nCond))
myloadT...
2013 Feb 12
0
Speexdec says: 'This doesn't look like a Speex file' (am I missing headers?)
...mChannelsPerFrame: 1
mBitsPerChannel: 16
} ...
} ...
}
sbufToTrackReadiness = 0x0
numSamples = 375
sampleTimingArray[1] = {
{PTS = {82626949766094/1000000000 = 82626.950, rounded}, DTS =
{INVALID}, duration = {1/44100 = 0.000}},
}
sampleSizeArray[1] = {
sampleSize = 2,
}
dataBuffer = 0x6e7a40
b) Actual data which is kept in aforementioned buffer (for the sake of
completeness):
0f001400 0b000d00 04000a00 f7ff1300 0a000300 f9ff1c00 1b001c00 f9ffc0ff
bfffadff b7ff86ff 7cff5fff 63ff67ff 84ffb5ff bbffd4ff e4ff1500 1c00100...
2013 Feb 12
0
Speexdec says: 'This doesn't look like a Speex file' (am I missing headers?).
...hannelsPerFrame: 1
mBitsPerChannel: 16
} ...
} ...
}
sbufToTrackReadiness = 0x0
numSamples = 375
sampleTimingArray[1] = {
{PTS = {82626949766094/1000000000 = 82626.950, rounded}, DTS = {INVALID}, duration = {1/44100 = 0.000}},
}
sampleSizeArray[1] = {
sampleSize = 2,
}
dataBuffer = 0x6e7a40
b) Actual data which is kept in aforementioned buffer (for the sake of completeness):
0f001400 0b000d00 04000a00 f7ff1300 0a000300 f9ff1c00 1b001c00 f9ffc0ff
bfffadff b7ff86ff 7cff5fff 63ff67ff 84ffb5ff bbffd4ff e4ff1500 1c00100...
2013 Feb 12
0
Speexdec says: 'This doesn't look like a Speex file' (am I missing headers?).
...mChannelsPerFrame: 1
mBitsPerChannel: 16
} ...
} ...
}
sbufToTrackReadiness = 0x0
numSamples = 375
sampleTimingArray[1] = {
{PTS = {82626949766094/1000000000 = 82626.950, rounded}, DTS =
{INVALID}, duration = {1/44100 = 0.000}},
}
sampleSizeArray[1] = {
sampleSize = 2,
}
dataBuffer = 0x6e7a40
b) Actual data which is kept in aforementioned buffer (for the sake of
completeness):
0f001400 0b000d00 04000a00 f7ff1300 0a000300 f9ff1c00 1b001c00 f9ffc0ff
bfffadff b7ff86ff 7cff5fff 63ff67ff 84ffb5ff bbffd4ff e4ff1500 1c00100...
2010 Sep 20
1
Removing slected values from original vector and definning new vector with the rest?
sampleSize <- 20
shape.true <- 1.82
scale.true <- 987
sampWB <- rweibull(sampleSize, shape=shape.true, scale=scale.true)
print(sampWB)
censidx <- sample(1:length(sampWB), length(sampWB)*0.3)
Censored.data <- sampWB[censidx]
noncensidx <- defines the rest values of the vector which is no...
2006 Mar 12
1
meta / lme
Hi
I'm conducing a meta-analysis using the meta package.
Here's a bit of code that works fine -
tmp <- metacont(samplesize.2, pctdropout.2, sddropout.2,
samplesize.1, pctdropout.1, sddropout.1,
data=Dataset, sm="WMD")
I would now like to control for a couple of variables (continuous and
categorical) that aren't in the equation.
Is meta inappropriate for these purposes? If so, based on...
2013 Feb 12
0
Speexdec says: 'This doesn't look like a Speex file' (am I missing headers?)
...hannelsPerFrame: 1
mBitsPerChannel: 16
} ...
} ...
}
sbufToTrackReadiness = 0x0
numSamples = 375
sampleTimingArray[1] = {
{PTS = {82626949766094/1000000000 = 82626.950, rounded}, DTS = {INVALID}, duration = {1/44100 = 0.000}},
}
sampleSizeArray[1] = {
sampleSize = 2,
}
dataBuffer = 0x6e7a40
b) Actual data which is kept in aforementioned buffer (for the sake of completeness):
0f001400 0b000d00 04000a00 f7ff1300 0a000300 f9ff1c00 1b001c00 f9ffc0ff
bfffadff b7ff86ff 7cff5fff 63ff67ff 84ffb5ff bbffd4ff e4ff1500 1c00100...
2015 Sep 09
0
sample.int() algorithms
...t together some sample code to show the difference in timing
letting sample.int() choose the cutoff point versus manually
specifying the use of do_sample2():
### compare times for sample.int() vs internal function sample2()
compareSampleTimes = function(popSizeList=c(1e5, 1e6, 1e7, 1e8, 1e9),
sampleSizeList=c(10, 100, 1000, 10000),
numReplications=1000) {
for (sampleSize in sampleSizeList) {
for (popSize in popSizeList) {
elapsed1 = system.time(replicate(numReplications,
sample.int(popSize, sampleSize)))[["elapsed"]]
elapsed2 = system.time(replica...
2018 Oct 05
2
Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)
On 05/10/2018, 09:45, "R-help on behalf of hmh" <r-help-bounces at r-project.org on behalf of hugomh at gmx.fr> wrote:
Hi,
Thanks William for this fast answer, and sorry for sending the 1st mail
to r-help instead to r-devel.
I noticed that bug while I was simulating many small random walks using
c(0,cumsum(rnorm(10))). Then the negative
2010 Sep 16
1
Weibull simulation- number of items to replace is not a multiple of replacement length
...simulation for weibull- estimating parameters by weibullMLE function,
Although I define metrix for the variables still I got this message: number of items to replace is not a multiple of replacement length
Any suggestion
> est=matrix (NA, 2,2)
> se=matrix (NA, 2,2)
> for ( p in 1:2) {
+ sampleSize <- 20
+ shape.true <- 1.82
+ scale.true <- 987
+ sampWB <- urweibull(sampleSize, shape=shape.true, scale=scale.true, lb=0, ub=Inf)
+ sampWBmleWB <- weibullMLE(sampWB)
+ est[p]= sampWBmleWB$estimate
+ se [p]= sampWBmleWB$s
+ }
Warning messages:
1: In est[p] = sampWBmleWB$estimate :...