| tact.stats {heR.Activities} | R Documentation |
Calculate weighted grouped statistics for a set of time-activity patterns across one or more time intervals and one or more event types, where subgroups are defined by a factor or list of factors
tact.stats(x, index, weights, breaks, codes, set = 1,
perc.byrow = TRUE, plotperc = FALSE)
x |
a mtact multiple-time-activity object |
index |
a factor or list of factors, where the factor(s) have length equal to the number of individuals in x |
weights |
probability weights corresponding to each individual in x, defaulting to equal weights for all individuals |
breaks |
time breaks defining the time intervals over which statistics will be calculated |
codes |
event types to be considered in the statistics, defaulting to all event types encountered across all individuals in all subgroups; names are used to label event codes in the resulting dataframe if they are available |
set |
the event set to use in x |
perc.byrow |
logical, calculate mean percentage time spent in events using a per-individual method (means across individual percentages) or an overall method (ratio of overall mean times spent in events to ovreall mean total time spent) |
plotperc |
logical, whether to plot the mean percentages of time spent across events for each subgroup or not |
The statistics consist of the following for each time interval:
Raw sample sizes are unweighted, but other statistics are calculated
using weights.
A "doer" is an individual who spends time in a certain event over the given interval. A "non-doer" spends *no* time in the event over the given interval.
The percentage of time spent by event can be calculated either as an average of individual (row) means or as the total time spent by the entire group divided by the total time spent by all individuals. The second method is identical to calculated a ratio of mean time spent in each event to the overall mean total time spent across all events. Note that the percentages may be calculated over a set of codes that do not fully identify all events in each individuals event series. The total time each individual spends in te given events may not tabulate to the duration of each time interval. In this case, the percentages are calculated only over the total time spent in the specified events.
The percentage of time spent by event can optionally be plotted as a set of horizontally stacked barplots with bars for each subgroup within each plot and a separate barplot for each time interval.
We split the multiple-time-activity object into groups, then further split these into time intervals, calculating statistics on each subgroup. The results are returned as a dataframe with a factors (group) column, an event codes column, and columns for each of the statistics listed above.
Note: This function replaces all of its predecessors: spap, aper, astat, apie, abar
Important Differences from tact.summarize
Unlike tact.summarize, this function reports on all of the time-activity information inside each time interval: the number of individuals engaged in selected events, the mean time spent, and the mean percentage of time spent. It is intended to be used with rather large time intervals (or a single large time intervval) in which different individuals are engaged in a variety of different activities.
In contrast, tact.summarize is intended to be used with rather small time intervals and only uses the event in each time interval that takes up the dominant time share for each individual (thus dropping information about other events in the time interval that the individual may visit, unlike tact.stats which reports on all events – or at least the specified ones) to report on the time series of the fraction of people spending (most of their) time in a given event. tact.summarize() takes a representative event per person for every time interval to create a quick, summary picture of a subpopulation's event time series characteristics.
The fractions in tact.summarize sum to one over all the people in each subgroup for a given time interval, whereas the percentage of doers in tact.stats do not sum to 100% for each time interval, since one person can be involved in more than one activity (a fact glossed over by tact.summarize). Although the mean percentages of time spent across all the events calculated by tact.stats sum to 100% for each time interval.
A dataframe with the following components:
INDEX |
a factor describing the subgroups |
TIME |
a factor describing the time intervals |
CODE |
the event codes |
RAW.N |
the raw number of individuals corresponding to the current subgroup and time interval (unweighted) |
RAW.DOER.N |
the raw number of individuals engaged in a given event for the current subgroup and time interval (unweighted) |
DOER.PERC |
the weighted percentage of individuals who were engaged in the event for the current subgroup |
OVRL.MEAN |
the weighted mean time spent in the event across all individuals in the current subgroup |
DOER.MEAN |
the weighted mean time spent in the event across only the "doers", i.e., those in the current group who were engaged in the event during the given time interval |
MEAN.PERC |
the mean percentage of time spent in the given event during the given time interval for individuals in the current subgroup |
Neil Klepeis