Re: [R] Calculation of Age heaping

2021-08-10 Thread Md. Moyazzem Hossain
Dear Richard O'Keefe,

Thank you very much.

Take care.

Md

On Tue, Aug 10, 2021 at 8:33 AM Richard O'Keefe  wrote:

> If you want to look at each digit, you should take a step back and
> think about what the
> Whipple index is actually doing.  Basically, the model underlying the
> Whipple index is
> that Pr(age = xy) = Pr(age = x*)Pr(age = *y) if there is no age
> heaping.  Or rather,
> since the age is restricted to 23..62 (a whole number of decades), it is
> that
> Pr(age - 23 = xy) = Pr(age - 23  = x*)Pr(age - 23 = *y) for 0 <= x <=
> 3, 0 <= y <= 9
> and the "nothing to see here" case is Pr(age = *y) = 1/10.
>
> I wasted way too much time trying to find a free age data set where
> age *wasn't* already
> grouped into 5 year bands.
>
> So what's wrong with a chi-square test?
> I would certainly want to check whether the high and low digits of age
> - 23 were in fact independent.
>
> On Mon, 9 Aug 2021 at 23:48, Md. Moyazzem Hossain 
> wrote:
> >
> > Dear Greg,
> >
> > Thank you very much for your suggestion. I will try it and follow your
> > advice.
> >
> > Actually, I want to find out the index for each digit like 0, 1, ..., 9.
> >
> > Thanks in advance. Take care.
> >
> > Md
> >
> >
> >
> > On Mon, Aug 9, 2021 at 12:05 PM Greg Minshall 
> wrote:
> >
> > > Md,
> > >
> > > if this is what you are looking for:
> > > 
> > > https://en.wikipedia.org/wiki/Whipple%27s_index
> > > 
> > >
> > > then, the article says the algorithm is
> > > 
> > > The index score is obtained by summing the number of persons in the age
> > > range 23 and 62 inclusive, who report ages ending in 0 and 5, dividing
> > > that sum by the total population between ages 23 and 62 years
> inclusive,
> > > and multiplying the result by 5. Restated as a percentage, index scores
> > > range between 100 (no preference for ages ending in 0 and 5) and 500
> > > (all people reporting ages ending in 0 and 5).
> > > 
> > >
> > > that seems fairly straight forward.  if you are trying to learn R,
> > > and/or learn programming, i might suggest you *not* use a package, and
> > > rather work on coding up the calculation yourself.  that would probably
> > > be a good, but not too hard, exercise, of some interest.  enjoy!
> > >
> > > cheers, Greg
> > >
> > >
> >
> > --
> > Best Regards,
> > Md. Moyazzem Hossain
> > Associate Professor
> > Department of Statistics
> > Jahangirnagar University
> > Savar, Dhaka-1342
> > Bangladesh
> > Website: http://www.juniv.edu/teachers/hossainmm
> > Research: *Google Scholar
> > *;
> > *ResearchGate
> > *; *ORCID iD
> > *
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>


-- 
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342
Bangladesh
Website: http://www.juniv.edu/teachers/hossainmm
Research: *Google Scholar
*;
*ResearchGate
*; *ORCID iD
*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculation of Age heaping

2021-08-10 Thread Richard O'Keefe
If you want to look at each digit, you should take a step back and
think about what the
Whipple index is actually doing.  Basically, the model underlying the
Whipple index is
that Pr(age = xy) = Pr(age = x*)Pr(age = *y) if there is no age
heaping.  Or rather,
since the age is restricted to 23..62 (a whole number of decades), it is that
Pr(age - 23 = xy) = Pr(age - 23  = x*)Pr(age - 23 = *y) for 0 <= x <=
3, 0 <= y <= 9
and the "nothing to see here" case is Pr(age = *y) = 1/10.

I wasted way too much time trying to find a free age data set where
age *wasn't* already
grouped into 5 year bands.

So what's wrong with a chi-square test?
I would certainly want to check whether the high and low digits of age
- 23 were in fact independent.

On Mon, 9 Aug 2021 at 23:48, Md. Moyazzem Hossain  wrote:
>
> Dear Greg,
>
> Thank you very much for your suggestion. I will try it and follow your
> advice.
>
> Actually, I want to find out the index for each digit like 0, 1, ..., 9.
>
> Thanks in advance. Take care.
>
> Md
>
>
>
> On Mon, Aug 9, 2021 at 12:05 PM Greg Minshall  wrote:
>
> > Md,
> >
> > if this is what you are looking for:
> > 
> > https://en.wikipedia.org/wiki/Whipple%27s_index
> > 
> >
> > then, the article says the algorithm is
> > 
> > The index score is obtained by summing the number of persons in the age
> > range 23 and 62 inclusive, who report ages ending in 0 and 5, dividing
> > that sum by the total population between ages 23 and 62 years inclusive,
> > and multiplying the result by 5. Restated as a percentage, index scores
> > range between 100 (no preference for ages ending in 0 and 5) and 500
> > (all people reporting ages ending in 0 and 5).
> > 
> >
> > that seems fairly straight forward.  if you are trying to learn R,
> > and/or learn programming, i might suggest you *not* use a package, and
> > rather work on coding up the calculation yourself.  that would probably
> > be a good, but not too hard, exercise, of some interest.  enjoy!
> >
> > cheers, Greg
> >
> >
>
> --
> Best Regards,
> Md. Moyazzem Hossain
> Associate Professor
> Department of Statistics
> Jahangirnagar University
> Savar, Dhaka-1342
> Bangladesh
> Website: http://www.juniv.edu/teachers/hossainmm
> Research: *Google Scholar
> *;
> *ResearchGate
> *; *ORCID iD
> *
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculation of Age heaping

2021-08-09 Thread Jim Lemon
Here is my hasty attempt last night checked in the light of morning.
It seems to return the correct extreme values and contains an example.

Jim

On Mon, Aug 9, 2021 at 10:50 PM Md. Moyazzem Hossain
 wrote:
>
> Dear Jim,
>
> Thank you very much for your kind help.
>
> Take care.
>
> Md
>
> On Mon, Aug 9, 2021 at 1:17 PM Jim Lemon  wrote:
>>
>> And if you really don't like programming:
>>
>> whipple_index<-function(x,td=c(0,5)) {
>>  wi<-rep(NA,11)
>>  names(wi)<-c(paste0("wi",0:9),"O/all")
>>  for(i in 0:9) {
>>   ttd<-which((x %% 10) %in% i)
>>   wi[i+1]<-length(ttd) * 100/length(x)
>>  }
>>  ttd<-which((x %% 10) %in% td)
>>  wi[11]<-length(ttd) * 100/(length(x)/length(td))
>>  return(wi)
>> }
>>
>> I haven't tested this extensively, but it may be helpful. You can
>> specify the final digits for the overall test. Select your ages before
>> passing them to whipple_index.
>>
>> Jim
>>
>> On Mon, Aug 9, 2021 at 9:05 PM Greg Minshall  wrote:
>> >
>> > Md,
>> >
>> > if this is what you are looking for:
>> > 
>> > https://en.wikipedia.org/wiki/Whipple%27s_index
>> > 
>> >
>> > then, the article says the algorithm is
>> > 
>> > The index score is obtained by summing the number of persons in the age
>> > range 23 and 62 inclusive, who report ages ending in 0 and 5, dividing
>> > that sum by the total population between ages 23 and 62 years inclusive,
>> > and multiplying the result by 5. Restated as a percentage, index scores
>> > range between 100 (no preference for ages ending in 0 and 5) and 500
>> > (all people reporting ages ending in 0 and 5).
>> > 
>> >
>> > that seems fairly straight forward.  if you are trying to learn R,
>> > and/or learn programming, i might suggest you *not* use a package, and
>> > rather work on coding up the calculation yourself.  that would probably
>> > be a good, but not too hard, exercise, of some interest.  enjoy!
>> >
>> > cheers, Greg
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Best Regards,
> Md. Moyazzem Hossain
> Associate Professor
> Department of Statistics
> Jahangirnagar University
> Savar, Dhaka-1342
> Bangladesh
> Website: http://www.juniv.edu/teachers/hossainmm
> Research: Google Scholar; ResearchGate; ORCID iD
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculation of Age heaping

2021-08-09 Thread Md. Moyazzem Hossain
Dear Jim,

Thank you very much for your kind help.

Take care.

Md

On Mon, Aug 9, 2021 at 1:17 PM Jim Lemon  wrote:

> And if you really don't like programming:
>
> whipple_index<-function(x,td=c(0,5)) {
>  wi<-rep(NA,11)
>  names(wi)<-c(paste0("wi",0:9),"O/all")
>  for(i in 0:9) {
>   ttd<-which((x %% 10) %in% i)
>   wi[i+1]<-length(ttd) * 100/length(x)
>  }
>  ttd<-which((x %% 10) %in% td)
>  wi[11]<-length(ttd) * 100/(length(x)/length(td))
>  return(wi)
> }
>
> I haven't tested this extensively, but it may be helpful. You can
> specify the final digits for the overall test. Select your ages before
> passing them to whipple_index.
>
> Jim
>
> On Mon, Aug 9, 2021 at 9:05 PM Greg Minshall  wrote:
> >
> > Md,
> >
> > if this is what you are looking for:
> > 
> > https://en.wikipedia.org/wiki/Whipple%27s_index
> > 
> >
> > then, the article says the algorithm is
> > 
> > The index score is obtained by summing the number of persons in the age
> > range 23 and 62 inclusive, who report ages ending in 0 and 5, dividing
> > that sum by the total population between ages 23 and 62 years inclusive,
> > and multiplying the result by 5. Restated as a percentage, index scores
> > range between 100 (no preference for ages ending in 0 and 5) and 500
> > (all people reporting ages ending in 0 and 5).
> > 
> >
> > that seems fairly straight forward.  if you are trying to learn R,
> > and/or learn programming, i might suggest you *not* use a package, and
> > rather work on coding up the calculation yourself.  that would probably
> > be a good, but not too hard, exercise, of some interest.  enjoy!
> >
> > cheers, Greg
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>


-- 
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342
Bangladesh
Website: http://www.juniv.edu/teachers/hossainmm
Research: *Google Scholar
*;
*ResearchGate
*; *ORCID iD
*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculation of Age heaping

2021-08-09 Thread Jim Lemon
And if you really don't like programming:

whipple_index<-function(x,td=c(0,5)) {
 wi<-rep(NA,11)
 names(wi)<-c(paste0("wi",0:9),"O/all")
 for(i in 0:9) {
  ttd<-which((x %% 10) %in% i)
  wi[i+1]<-length(ttd) * 100/length(x)
 }
 ttd<-which((x %% 10) %in% td)
 wi[11]<-length(ttd) * 100/(length(x)/length(td))
 return(wi)
}

I haven't tested this extensively, but it may be helpful. You can
specify the final digits for the overall test. Select your ages before
passing them to whipple_index.

Jim

On Mon, Aug 9, 2021 at 9:05 PM Greg Minshall  wrote:
>
> Md,
>
> if this is what you are looking for:
> 
> https://en.wikipedia.org/wiki/Whipple%27s_index
> 
>
> then, the article says the algorithm is
> 
> The index score is obtained by summing the number of persons in the age
> range 23 and 62 inclusive, who report ages ending in 0 and 5, dividing
> that sum by the total population between ages 23 and 62 years inclusive,
> and multiplying the result by 5. Restated as a percentage, index scores
> range between 100 (no preference for ages ending in 0 and 5) and 500
> (all people reporting ages ending in 0 and 5).
> 
>
> that seems fairly straight forward.  if you are trying to learn R,
> and/or learn programming, i might suggest you *not* use a package, and
> rather work on coding up the calculation yourself.  that would probably
> be a good, but not too hard, exercise, of some interest.  enjoy!
>
> cheers, Greg
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculation of Age heaping

2021-08-09 Thread Richard O'Keefe
t; > the current value being looked at is N, you simply increment counter[N] or
> > of N-1 or whatever your logic requires.
> >
> > Alternately R has many built-in methods (or in other packages) like cut()
> > that might do something similar without as much work.
> >
> > And just for the heck of it, I tried your download instructions. Unlike
> > your three choices, I was offered 13 choices and as I had no clue what YOU
> > were supposed to download, I aborted.
> >
> >  1: All
> > 2: CRAN packages only
> > 3: None
> > 4: colorspace (2.0-1 -> 2.0-2) [CRAN]
> > 5: isoband(0.2.4 -> 0.2.5) [CRAN]
> > 6: utf8   (1.2.1 -> 1.2.2) [CRAN]
> > 7: cli(3.0.0 -> 3.0.1) [CRAN]
> > 8: ggplot2(3.3.3 -> 3.3.5) [CRAN]
> > 9: pillar     (1.6.1 -> 1.6.2) [CRAN]
> > 10: tibble (3.1.2 -> 3.1.3) [CRAN]
> > 11: dplyr  (1.0.6 -> 1.0.7) [CRAN]
> > 12: Rcpp   (1.0.6 -> 1.0.7) [CRAN]
> > 13: curl   (4.3.1 -> 4.3.2) [CRAN]
> > 14: cpp11  (0.2.7 -> 0.3.1) [CRAN]
> >
> > In your case, if you selected All, what exactly did you expect?
> >
> >
> > -Original Message-
> > From: R-help  On Behalf Of Md. Moyazzem
> > Hossain
> > Sent: Sunday, August 8, 2021 5:25 PM
> > To: r-help@r-project.org
> > Subject: [R] Calculation of Age heaping
> >
> > Dear R-expert,
> >
> > I hope that you are doing well.
> >
> > I am interested to calculate the age heaping for each digit (0,1,...,9)
> > based on my data set. However, when I run the R code, I got the following
> > errors. Please help me in this regard.
> >
> > ##
> > library(remotes)
> > install_github("timriffe/DemoTools")
> >
> > ###
> > Downloading GitHub repo timriffe/DemoTools@HEAD These packages have more
> > recent versions available.
> > It is recommended to update all of them.
> > Which would you like to update?
> >
> >  1: All
> >  2: CRAN packages only
> >  3: None
> >
> > Enter one or more numbers, or an empty line to skip updates: 1
> >
> > *After installing some packages, I got the following error message*
> >
> > package ‘backports’ successfully unpacked and MD5 sums checked
> > Error: Failed to install 'DemoTools' from GitHub:
> >   (converted from warning) cannot remove prior installation of package
> > ‘backports’
> >
> > I am attaching the R-code and data file along with this email.
> >
> > Please help me in this regard.
> >
> > Thanks in advance.
> > --
> > Best Regards,
> > Md. Moyazzem Hossain
> > Associate Professor
> > Department of Statistics
> > Jahangirnagar University
> > Savar, Dhaka-1342
> > Bangladesh
> > Website: http://www.juniv.edu/teachers/hossainmm
> > Research: *Google Scholar
> > <https://scholar.google.com/citations?user=-U03XCgJ=en=ao>*;
> > *ResearchGate
> > <https://www.researchgate.net/profile/Md_Hossain107>*; *ORCID iD
> > <https://orcid.org/-0003-3593-6936>*
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
> --
> Best Regards,
> Md. Moyazzem Hossain
> Associate Professor
> Department of Statistics
> Jahangirnagar University
> Savar, Dhaka-1342
> Bangladesh
> Website: http://www.juniv.edu/teachers/hossainmm
> Research: *Google Scholar
> <https://scholar.google.com/citations?user=-U03XCgJ=en=ao>*;
> *ResearchGate
> <https://www.researchgate.net/profile/Md_Hossain107>*; *ORCID iD
> <https://orcid.org/-0003-3593-6936>*
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculation of Age heaping

2021-08-09 Thread Md. Moyazzem Hossain
Dear Greg,

Thank you very much for your suggestion. I will try it and follow your
advice.

Actually, I want to find out the index for each digit like 0, 1, ..., 9.

Thanks in advance. Take care.

Md



On Mon, Aug 9, 2021 at 12:05 PM Greg Minshall  wrote:

> Md,
>
> if this is what you are looking for:
> 
> https://en.wikipedia.org/wiki/Whipple%27s_index
> 
>
> then, the article says the algorithm is
> 
> The index score is obtained by summing the number of persons in the age
> range 23 and 62 inclusive, who report ages ending in 0 and 5, dividing
> that sum by the total population between ages 23 and 62 years inclusive,
> and multiplying the result by 5. Restated as a percentage, index scores
> range between 100 (no preference for ages ending in 0 and 5) and 500
> (all people reporting ages ending in 0 and 5).
> 
>
> that seems fairly straight forward.  if you are trying to learn R,
> and/or learn programming, i might suggest you *not* use a package, and
> rather work on coding up the calculation yourself.  that would probably
> be a good, but not too hard, exercise, of some interest.  enjoy!
>
> cheers, Greg
>
>

-- 
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342
Bangladesh
Website: http://www.juniv.edu/teachers/hossainmm
Research: *Google Scholar
*;
*ResearchGate
*; *ORCID iD
*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculation of Age heaping

2021-08-09 Thread Greg Minshall
Md,

if this is what you are looking for:

https://en.wikipedia.org/wiki/Whipple%27s_index


then, the article says the algorithm is

The index score is obtained by summing the number of persons in the age
range 23 and 62 inclusive, who report ages ending in 0 and 5, dividing
that sum by the total population between ages 23 and 62 years inclusive,
and multiplying the result by 5. Restated as a percentage, index scores
range between 100 (no preference for ages ending in 0 and 5) and 500
(all people reporting ages ending in 0 and 5).


that seems fairly straight forward.  if you are trying to learn R,
and/or learn programming, i might suggest you *not* use a package, and
rather work on coding up the calculation yourself.  that would probably
be a good, but not too hard, exercise, of some interest.  enjoy!

cheers, Greg

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculation of Age heaping

2021-08-09 Thread Md. Moyazzem Hossain
Dear Avi Gross,

Thank you very much for your email. Actually, I have a little knowledge of
R programming.

I have a dataset of ages ranging from 10 to 90. Now, I want to find out the
Whipple’s index for age heaping among individuals for each digit like
0,1,...,9.

I have searched in google I got the following functions. That's why I use
the package and the following code.

*check_heaping_whipple(Value, Age, ageMin = 25, ageMax = 65, digit = c(0,
5)) * [link:
https://rdrr.io/github/timriffe/DemoTools/man/check_heaping_whipple.html]

Thanks in advance.

Md



On Sun, Aug 8, 2021 at 10:48 PM Avi Gross via R-help 
wrote:

> It is not too clear to me what you want to do and why that package is the
> way to do it. Is the package a required part of your assignment? If so,
> maybe someone else can help you find how to properly install it on your
> machine, assuming you have permissions to replace the other package it
> seems to require. You may need to create your own environment. If you are
> open to other ways, see below.
>
> Are you trying to do something as simple as counting how many people in
> your data are in various buckets such as each age truncated or rounded to
> an integer from 0 to 99? If so, you might miss some of my cousins alive at
> 100 or that died at 103 and 105 recently 
>
> Or do you want ages in groups of 10 or so meaning the first of two digits
> is 0 through 9?
>
> Many such things can be done quite easily without the package if you wish.
>
> As far as I can tell, your code reads in a data.frame from your local file
> with any number of columns that you do not specify. If it is one, the
> solution becomes much easier. You then for some reason feel the need to
> convert it to a matrix. You then do whatever your Whipple does several ways.
>
> Here is an outline of ways you can do this yourself.
>
> First, combine all your data into one or more vectors. You already have
> that in your data.frame but if all columns are numeric, you can of course
> do something with a matrix.
>
> Then make sure you remove anything objectionable, such as negative numbers
> or numbers too large or NA or whatever your logic requires.
>
> If you have a variable ready with N entries to hold the buckets, such as
> length(0:100) or for even buckets of 5, perhaps length(0:99)/5 you
> initialize that to all zeroes.
>
> Now take your data, and perhaps transform it into a copy where every age
> is truncated to an integer or divided by 5 first or whatever you need so it
> contains a pure integer like 6 or 12. What I mean is if your buckets are 5
> wide, and you want 5:9 to map into one bucket, your transform might be
> as.integer(original/5.0) or one of many variants like that.
>
> You can now simply use one of many methods in R to loop through your
> values that result and assuming you have a zeroed vector called counter and
> the current value being looked at is N, you simply increment counter[N] or
> of N-1 or whatever your logic requires.
>
> Alternately R has many built-in methods (or in other packages) like cut()
> that might do something similar without as much work.
>
> And just for the heck of it, I tried your download instructions. Unlike
> your three choices, I was offered 13 choices and as I had no clue what YOU
> were supposed to download, I aborted.
>
>  1: All
> 2: CRAN packages only
> 3: None
> 4: colorspace (2.0-1 -> 2.0-2) [CRAN]
> 5: isoband(0.2.4 -> 0.2.5) [CRAN]
> 6: utf8   (1.2.1 -> 1.2.2) [CRAN]
> 7: cli(3.0.0 -> 3.0.1) [CRAN]
> 8: ggplot2(3.3.3 -> 3.3.5) [CRAN]
> 9: pillar (1.6.1 -> 1.6.2) [CRAN]
> 10: tibble (3.1.2 -> 3.1.3) [CRAN]
> 11: dplyr  (1.0.6 -> 1.0.7) [CRAN]
> 12: Rcpp   (1.0.6 -> 1.0.7) [CRAN]
> 13: curl   (4.3.1 -> 4.3.2) [CRAN]
> 14: cpp11  (0.2.7 -> 0.3.1) [CRAN]
>
> In your case, if you selected All, what exactly did you expect?
>
>
> -Original Message-
> From: R-help  On Behalf Of Md. Moyazzem
> Hossain
> Sent: Sunday, August 8, 2021 5:25 PM
> To: r-help@r-project.org
> Subject: [R] Calculation of Age heaping
>
> Dear R-expert,
>
> I hope that you are doing well.
>
> I am interested to calculate the age heaping for each digit (0,1,...,9)
> based on my data set. However, when I run the R code, I got the following
> errors. Please help me in this regard.
>
> ##
> library(remotes)
> install_github("timriffe/DemoTools")
>
> ###
> Downloading GitHub repo timriffe/DemoTools@HEAD These packages have more
> recent versions available.
> It is recommended to update all of them.
> Which would you like to update?
>
>  1: All
>  2: CRAN packages only
>  3: None
>

Re: [R] Calculation of Age heaping

2021-08-08 Thread Avi Gross via R-help
It is not too clear to me what you want to do and why that package is the way 
to do it. Is the package a required part of your assignment? If so, maybe 
someone else can help you find how to properly install it on your machine, 
assuming you have permissions to replace the other package it seems to require. 
You may need to create your own environment. If you are open to other ways, see 
below.

Are you trying to do something as simple as counting how many people in your 
data are in various buckets such as each age truncated or rounded to an integer 
from 0 to 99? If so, you might miss some of my cousins alive at 100 or that 
died at 103 and 105 recently 

Or do you want ages in groups of 10 or so meaning the first of two digits is 0 
through 9?

Many such things can be done quite easily without the package if you wish.

As far as I can tell, your code reads in a data.frame from your local file with 
any number of columns that you do not specify. If it is one, the solution 
becomes much easier. You then for some reason feel the need to convert it to a 
matrix. You then do whatever your Whipple does several ways.

Here is an outline of ways you can do this yourself.

First, combine all your data into one or more vectors. You already have that in 
your data.frame but if all columns are numeric, you can of course do something 
with a matrix.

Then make sure you remove anything objectionable, such as negative numbers or 
numbers too large or NA or whatever your logic requires.

If you have a variable ready with N entries to hold the buckets, such as 
length(0:100) or for even buckets of 5, perhaps length(0:99)/5 you initialize 
that to all zeroes.

Now take your data, and perhaps transform it into a copy where every age is 
truncated to an integer or divided by 5 first or whatever you need so it 
contains a pure integer like 6 or 12. What I mean is if your buckets are 5 
wide, and you want 5:9 to map into one bucket, your transform might be 
as.integer(original/5.0) or one of many variants like that.

You can now simply use one of many methods in R to loop through your values 
that result and assuming you have a zeroed vector called counter and the 
current value being looked at is N, you simply increment counter[N] or of N-1 
or whatever your logic requires.

Alternately R has many built-in methods (or in other packages) like cut() that 
might do something similar without as much work.

And just for the heck of it, I tried your download instructions. Unlike your 
three choices, I was offered 13 choices and as I had no clue what YOU were 
supposed to download, I aborted.

 1: All   
2: CRAN packages only
3: None  
4: colorspace (2.0-1 -> 2.0-2) [CRAN]
5: isoband(0.2.4 -> 0.2.5) [CRAN]
6: utf8   (1.2.1 -> 1.2.2) [CRAN]
7: cli(3.0.0 -> 3.0.1) [CRAN]
8: ggplot2(3.3.3 -> 3.3.5) [CRAN]
9: pillar (1.6.1 -> 1.6.2) [CRAN]
10: tibble (3.1.2 -> 3.1.3) [CRAN]
11: dplyr  (1.0.6 -> 1.0.7) [CRAN]
12: Rcpp   (1.0.6 -> 1.0.7) [CRAN]
13: curl   (4.3.1 -> 4.3.2) [CRAN]
14: cpp11  (0.2.7 -> 0.3.1) [CRAN]

In your case, if you selected All, what exactly did you expect?


-Original Message-
From: R-help  On Behalf Of Md. Moyazzem Hossain
Sent: Sunday, August 8, 2021 5:25 PM
To: r-help@r-project.org
Subject: [R] Calculation of Age heaping

Dear R-expert,

I hope that you are doing well.

I am interested to calculate the age heaping for each digit (0,1,...,9) based 
on my data set. However, when I run the R code, I got the following errors. 
Please help me in this regard.

##
library(remotes)
install_github("timriffe/DemoTools")

###
Downloading GitHub repo timriffe/DemoTools@HEAD These packages have more recent 
versions available.
It is recommended to update all of them.
Which would you like to update?

 1: All
 2: CRAN packages only
 3: None

Enter one or more numbers, or an empty line to skip updates: 1

*After installing some packages, I got the following error message*

package ‘backports’ successfully unpacked and MD5 sums checked
Error: Failed to install 'DemoTools' from GitHub:
  (converted from warning) cannot remove prior installation of package 
‘backports’

I am attaching the R-code and data file along with this email.

Please help me in this regard.

Thanks in advance.
--
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342
Bangladesh
Website: http://www.juniv.edu/teachers/hossainmm
Research: *Google Scholar
<https://scholar.google.com/citations?user=-U03XCgJ=en=ao>*;
*ResearchGate
<https://www.researchgate.net/profile/Md_Hossain107>*; *ORCID iD
<https://orcid.org/-0003-3593-6936>*

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/

[R] Calculation of Age heaping

2021-08-08 Thread Md. Moyazzem Hossain
Dear R-expert,

I hope that you are doing well.

I am interested to calculate the age heaping for each digit (0,1,...,9)
based on my data set. However, when I run the R code, I got the following
errors. Please help me in this regard.

##
library(remotes)
install_github("timriffe/DemoTools")

###
Downloading GitHub repo timriffe/DemoTools@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

 1: All
 2: CRAN packages only
 3: None

Enter one or more numbers, or an empty line to skip updates: 1

*After installing some packages, I got the following error message*

package ‘backports’ successfully unpacked and MD5 sums checked
Error: Failed to install 'DemoTools' from GitHub:
  (converted from warning) cannot remove prior installation of package
‘backports’

I am attaching the R-code and data file along with this email.

Please help me in this regard.

Thanks in advance.
-- 
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342
Bangladesh
Website: http://www.juniv.edu/teachers/hossainmm
Research: *Google Scholar
*;
*ResearchGate
*; *ORCID iD
*

###
library(remotes)
install_github("timriffe/DemoTools")

library(DemoTools)

###
Age <- 0:99
length(Age)

data=read.csv("D:/age.csv", header=FALSE)
pop1m_pasex=as.matrix(data)
length(pop1m_pasex)

w05 <- check_heaping_whipple(pop1m_pasex, Age, 25, 60, digit = c(0,5))

w0 <- check_heaping_whipple(pop1m_pasex, Age, 25, 60, digit = 0)
w5 <- check_heaping_whipple(pop1m_pasex, Age, 25, 60, digit = 5)

# Whipple types
w3=check_heaping_whipple(pop1m_pasex, Age, 25, 60, digit = 3)


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.