lsmeans and continuous time - mixed-models

I would like to have your help on this problem.
I wish to express the evolution of a quality of life score over the time with adjustment on clinical factors.
I work on a cohort of more than 1000 patients and a quality of life form was delivered every 3 months. Time is considered continuous as patients did not fill the form exactly at same time.
Here is my problem I used a linear mixed model with fixed factors (the sex and the prognosis). I would like to obtain the average score at 3, 6, 9 and 12 months from this model. I used the lsmeans function but the score obtained corresponds to average time.
How can I get average scores from my model at these 4 different times?
You will find below my code and the result I get with lsmeans
mod_mix2 <- lme(score_utilite~delai+prono1+sex1,random = ~ delai|numero_patient, data = qdv,na.action=na.omit,method="ML")
lsmeans(mod_mix2, specs ="delai")
$lsmeans
delai lsmean SE df lower.CL upper.CL
10.21976 0.8145542 0.005835597 1016 0.803103 0.8260054
Results are averaged over the levels of: prono1, sex1
Confidence level used: 0.95
$contrasts
contrast estimate SE df z.ratio p.value
(nothing) nonEst NA NA NA NA
Results are averaged over the levels of: prono1, sex1
Thank you very much

Try
lsmeans(mod_mix2, specs ="delai",
at = list(delai = c(3,6,8,12)))

Related

DAX: Averaging multiple % Columns

I'm new to Power BI and Dax, having some difficulty with the below scenario.
test a b c d AVERAGE
aa 51.97% 46.61% 49%
I have 4 columns, a-d, and I simply want the average of the 4 columns in the AVERAGE column. Dependent on the row different columns may be blank. Each of the columns are measures pulling through a % value into the table.
I'm sure there must be a simple solution to this but any help would be much appreciated.
Try creating a column like this:
AVERAGE = ([a]+[b]+[c]+[d])/4
UPDATE: BLANK measures don't affect average result.
AVERAGE = DIVIDE(([a]+[b]+[c]+[d]),
(IF(ISBLANK([a]),0,1) + IF(ISBLANK([b]),0,1) +
IF(ISBLANK([c]),0,1) + IF(ISBLANK([d]),0,1)))

Creating Dual Axis with "long" data

I am new to Tableau. I have a dataset made up of year, has a measure that can be one of many values, and a corresponding value for that measure. Example:
YEAR MEASURE Value
1988 Number of Cars 10
1989 Number of Cars 15
1988 Number of Peds 5
1989 Number of Peds 6
This is just an example data set. But, I want to create bar char for Number of Cars and a line graph for Number of Peds. How can this be done? I was told I can do this without reorganizing the dataset (into a wide data set).
thanks
jason
You can create two calculated fields to separate Cars from Peds counts as follows:
if [measure name] = 'cars' then value end
Repeat for Peds. Then follow these instructions for dual axis.
https://onlinehelp.tableau.com/current/pro/desktop/en-us/multiplemeasures_dualaxes.html

Economic model and hazard damage in matlab

first, i want to say i am relatively new with matlab and so i am not yet very good in it.
I have the variables A,K and L and the constant alpha. Out of this, i want to model the income Y.
Y=A^alpha*K*L;
L changes at a growth rate of 0.09;
dL/dt= rl;
with L population growth; L0 (1950)=500;
I need to model this for 50 years, how can i do this in matlab? so, L has to grow every year, but with the stuff i tried i get always one output value, not 50 values (one for every year): how i have to code this in matlab?
at the moment, I have this, but it gives just the L0*(1+r) for every year
for i = 1:50
dL(i)=(1+r).*L
end
and the growth rate is continuus, but in one year I have due to an event (financial crisis for example) include a population decrease of 7% in one year, for example after year 30. Thereafther, the population will grow at same rate as before. How i can do this in matlab?
thanks for answering.
Actually it works, i had made a mistake by defining the loop from i:50, it must be from n:50

How to compute & plot Equal Error Rate (EER) from FAR/FRR values using matlab

I have the following values against FAR/FRR. i want to compute EER rates and then plot in matlab.
FAR FRR
19.64 20
21.29 18.61
24.92 17.08
19.14 20.28
17.99 21.39
16.83 23.47
15.35 26.39
13.20 29.17
7.92 42.92
3.96 60.56
1.82 84.31
1.65 98.33
26.07 16.39
29.04 13.13
34.49 9.31
40.76 6.81
50.33 5.42
66.83 1.67
82.51 0.28
Is there any matlab function available to do this. can somebody explain this to me. Thanks.
Let me try to answer your question
1) For your data EER can be the mean/max/min of [19.64,20]
1.1) The idea of EER is try to measure the system performance against another system (the lower the better) by finding the equal(if not equal then at least nearly equal or have the min distance) between False Alarm Rate (FAR) and False Reject Rate (FRR, or missing rate) .
Refer to your data, [19.64,20] gives min distance, thus it could used as EER, you can take mean/max/min value of these two value, however since it means to compare between systems, thus make sure other system use the same method(mean/max/min) to pick EER value.
The difference among mean/max/min can be ignored if the there are large amount of data. In some speaker verification task, there will be 100k data sample.
2) To understand EER ,better compute it by yourself, here is how:
two things you need to know:
A) The system score for each test case (trial)
B) The true/false for each trial
After you have A and B, then you can create [trial, score,true/false] pairs then sort it by the score value, after that loop through the score, eg from min-> max. At each loop assume threshold is that score and compute the FAR,FRR. After loop through the score find the FAR,FRR with "equal" value.
For the code you can refer to my pyeer.py , in function processDataTable2
https://github.com/StevenLOL/Research_speech_speaker_verification_nist_sre2010/blob/master/SRE2010/sid/pyeer.py
This function is written for the NIST SRE 2010 evaluation.
4) There are other measures similar to EER, such as minDCF which only play with the weights of FAR and FRR. You can refer to "Performance Measure" of http://www.nist.gov/itl/iad/mig/sre10results.cfm
5) You can also refer to this package https://sites.google.com/site/bosaristoolkit/ and DETware_v2.1.tar.gz at http://www.itl.nist.gov/iad/mig/tools/ for computing and plotting EER in Matlab
Plotting in DETWare_v2.1
Pmiss=1:50;Pfa=50:-1:1;
Plot_DET(Pmiss/100.0,Pfa/100.0,'r')
FAR(t) and FRR(t) are parameterized by threshold, t. They are cumulative distributions, so they should be monotonic in t. Your data is not shown to be monotonic, so if it is indeed FAR and FRR, then the measurements were not made in order. But for the sake of clarity, we can order:
FAR FRR
1 1.65 98.33
2 1.82 84.31
3 3.96 60.56
4 7.92 42.92
5 13.2 29.17
6 15.35 26.39
7 16.83 23.47
8 17.99 21.39
9 19.14 20.28
10 19.64 20
11 21.29 18.61
12 24.92 17.08
13 26.07 16.39
14 29.04 13.13
15 34.49 9.31
16 40.76 6.81
17 50.33 5.42
18 66.83 1.67
19 82.51 0.28
This is for increasing FAR, which assumes a distance score; if you have a similarity score, then FAR would be sorted in decreasing order.
Loop over FAR until it is larger than FRR, which occurs at row 11. Then interpolate the cross over value between rows 10 and 11. This is your equal error rate.

Group of consecutive minimum values within data - MATLAB

I have daily river flow data for 1975-2009 and I am asked to find the 7 consecutive days within each year that have the smallest flows.
Any advice how to start this? I've only been using MATLAB for a couple weeks.
Thanks!
You could convolve the data with ones(1,7) and look for the minimum, which will yield the starting day of your dry period:
[~,startingDay] = min(conv(flow,ones(1,7),'valid'))
(This is basically a moving average filter without the normalization).
Loop through the years to get each year's result.
Start by finding cumulative sum with cumsum. The difference between cumulative sums 7 days apart will give you the total for those 7 days. Then pick the minimum of those.
a = cumsum(flow);
b = a(8:end) - a(1:end-7);
[m,i] = min(b);
Here m holds the smallest total over 7 consecutive days, and i is a vector of indices telling you when they occurred.