My data are not statistically independent, that is why I want to use N*.

So what I've done is modify a function I found here:
http://stackoverflow.com/questions/20425473/calculate-confidence-interval-in-julia

to do what I want:

function t_test(x::Array{Float64,1};
                nstar=0, conf_level=0.95)
    alpha = (1. - conf_level)
    if nstar == 0
        nstar=length(x) - 1
    end
    tstar = quantile(TDist(nstar - 1), 1 - alpha / 2)
    SE = std(x) / sqrt(nstar)
    lo, hi = mean(x) + [-1, 1] * tstar * SE
end





On Tuesday, November 10, 2015 at 4:48:39 PM UTC+1, j verzani wrote:
>
> If you have the sample data, it is just the length of the data minus 1, so 
> does not need to be specified, as it is computed.
>
> On Tuesday, November 10, 2015 at 9:47:43 AM UTC-5, Evan wrote:
>>
>> I want to do the following with some time series data:
>>
>> Calculate 95% confidence interval for mean defined as 
>> +/-sigma(x)qt(0.025, N*-1) / sqrt(N*) where sigma(x) is the standard 
>> deviation at any point x and qt(0.025, N*-1) is the 2.5 percentage point of 
>> the Student-t distribution with N*-1 degrees of freedom.
>>
>> I have been trying to do this with HypothesisTests' ci() and 
>> OneSampleTTest() functions, but as far as I can see OneSampleTTest() does 
>> not allow me to choose the number of degrees of freedom.
>>
>> julia> t = OneSampleTTest(arr)
>> One sample t-test
>> -----------------
>> Population details:
>>     parameter of interest:   Mean
>>     value under h_0:         0
>>     point estimate:          0.3835
>>     95% confidence interval: (0.14217301685460967,0.6248269831453903)
>>
>> Test summary:
>>     outcome with 95% confidence: reject h_0
>>     two-sided p-value:           0.0057946078675091515 (very significant)
>>
>> Details:
>>     number of observations:   10
>>     t-statistic:              3.5948622927526235
>>     degrees of freedom:       9
>>     empirical standard error: 0.10668002520517972
>>
>>
>> julia> t.df
>> 9
>> julia> ci(t, 0.025, tail=:both)
>> (0.09706297518543938,0.6699370248145606)
>>
>>
>> Can anybody point me in the right direction?
>>
>>
>>
>>

Reply via email to