Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions about calculating livelihoods status scores #27

Open
MijuKim opened this issue Oct 12, 2017 · 3 comments
Open

Questions about calculating livelihoods status scores #27

MijuKim opened this issue Oct 12, 2017 · 3 comments

Comments

@MijuKim
Copy link

MijuKim commented Oct 12, 2017

Hi,

I'm working on 'functions.R' to calculate livelihoods status scores. What I found and understood is that it averages jobs and wages scores for last 5 years (e.g. 2010 - 2014) not for the latest one year (e.g. 2014).

I just copied that part of the code:

mutate( x_jobs = pmax(-1, pmin(1, jobs_sum / jobs_sum_first)), x_wages = pmax(-1, pmin(1, wages_avg / wages_avg_first)), score = mean(c(x_jobs, x_wages), na.rm=T) * 100)

I attached a middle result of status score.

liv_status_score.xlsx

I'd like to know whether this (5-year-average) is right, or it is corrected later on functions.r. I'm not an expert on R so that there is high probability that I missunderstood.

It would be great if anyone can help on this.

Thanks,
Miju

@jules32
Copy link
Contributor

jules32 commented Oct 12, 2017

Hi @MijuKim, thanks for the question.

I think you're understanding R really well! I've looked at the code you pasted above and I understand your question. This is what you pasted in the excel file:

region_id  year jobs_sum wages_avg jobs_sum_first wages_avg_first    x_jobs   x_wages    score
      <int> <int>    <dbl>     <dbl>          <dbl>           <dbl>     <dbl>     <dbl>    <dbl>
1         0  2010 620374.2  43625136       620374.2        43625136 1.0000000 1.0000000 98.38118
2         0  2011 585561.9  44633911       620374.2        43625136 0.9438849 1.0000000 98.38118
3         0  2012 593994.1  45458780       620374.2        43625136 0.9574771 1.0000000 98.38118
4         0  2013 611679.0  44843201       620374.2        43625136 0.9859839 1.0000000 98.38118
5         0  2014 613159.0  41984945       620374.2        43625136 0.9883697 0.9624026 98.38118

It is not averaging over the past 5 years but it is comparing the most recent year (2014) to the reference year, which is 5 years ago (2010). All years of the x_jobs variable are being calculated in reference to the jobs_sum and wages_avg from the reference year, which is 2010. (So those columns jobs_sum_first and wages_avg_first are copies of the data from the reference year, 2010).

Let me know if you have other questions!

@MijuKim
Copy link
Author

MijuKim commented Oct 18, 2017

score = (x_jobs + x_wages) / 2 * 100)

@MijuKim
Copy link
Author

MijuKim commented Oct 18, 2017

Julie and I already talked about this.
But I left the changed results just for record.

region_id year jobs_sum wages_avg jobs_sum_first wages_avg_first x_jobs x_wages score
0 2010 620374.2 4.36E+13 620374.2 4.36E+13 1 1 100
0 2011 585561.9 4.46E+13 620374.2 4.36E+13 0.943885 1 97.19425
0 2012 593994.1 4.55E+13 620374.2 4.36E+13 0.957477 1 97.87386
0 2013 611679 4.48E+13 620374.2 4.36E+13 0.985984 1 99.29919
0 2014 613159 4.20E+13 620374.2 4.36E+13 0.98837 0.962403 97.53861

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants