GithubHelp home page GithubHelp logo

jazznbass / scan Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 41.18 MB

Development version of scan: Single-Case Data Analyses for Single and Multiple Baseline Designs

Home Page: https://jazznbass.github.io/scan/.

License: GNU General Public License v3.0

R 100.00%

scan's People

Contributors

jazznbass avatar researchtool avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

jannisbosch

scan's Issues

Grouped analyses

The next step for single-case data analysis is to join single and group based analyses. The idea here is to filter or group single-cases by a variable (e.g. gender or migration_background) and compare results for these grouped single-cases.
in hplm() this is achieved through a level-two dataset comprised of the same casenames as the scdf and additional level-2 variables.
Maybe similar ideas could be applied to other types of analyses.
First, we need to extend the scdf data-structure.

Possibilities to do that:

  1. rely on a second dataframe with level-2 variables (like now in hplm()
  2. add new variables to the dataframes of each single-case in the scdf with constant values (like in long format data structures e.g. used in multilevel analyses lmer() or lme()
  3. add a list of attributes to each dataframe of the scdf.

I favour option 1 (with an internal conversion to option 2 if needed).

The longSCDF() function of scan already does the job of joining scdf and level-2 dataframes.

Saving plots

First of all, I appreciate the scan package and the scan book. Thanks!

I have an issue in that I am trying to save the plots using the scplot package. I am aware that it is considered experimental at this phase of development and perhaps there is no current solution to my issue. Also, I understand that the plots generated using scplot are ggplot objects and therefore can be 'modified and extended' as wished. My issue is that while I am able to generate plots, I am unable to export them using ggsave function as I do with standard ggplot objects. I get the following error:

Error in UseMethod("grid.draw") :
no applicable method for 'grid.draw' applied to an object of class "scplot"

Again, thanks for the packages. Any assistance you can provide with this issue is appreciated.

Meta analysis

We have an increasing demand for meta analysis.

Instead of implementing a meta-analysis within every function, a better way might be to have a separate function that takes the return of various analyses and conducts a meta analyses on them.

The generic function might be:
meta_analysis()

The method dispatch might be a bit scruffy: All our S3 objects have "two" classes (sc and a specific class; this is not very nice because actually this should indicate an inheritance relationship!):

  1. old school dirty way -> one method for sc class and go on from there with calls depending on the second class argument.
  2. a workaround -> a method for class sc calls the next method for the second class
  3. clean -> rewrite all classnames (e.g. sc_describe, sc_plm).
    I am in favour of the third method. But it might break some code if someone out there worked with our current classes - but that is highly improbable.

Exporting power analyses

Discussed in #80

Originally posted by gjones1219 October 20, 2022
Hello! Thank you again for creating this very helpful package.

Quick, simple question -- how can one export the results from power analyses in scan? The export function seems to work for the models, but does not work for power analyses. Furthermore, I have tried converting the power analyses (an "sc_power" object) into another class of object (i.e., a data table), but the formatting gets messed up when I do so. It would be great to have a simple way to export these power analyses to put them into a paper. Thank you!

problem with csv data import (lost mt)

When importing data from a csv I'm losing the measurement times (scan 0.54.1).
Import works but the scdf doesn't have a mt variable.

reproducible example with attached csv-file bsp-import.csv:
read_scdf("bsp-import.csv")
read_scdf("bsp-import.csv", mvar = "mt")

dat <- readSC("bsp-import.csv")
Loaded 2 cases.
str(dat)
List of 2
$ Hans :'data.frame': 6 obs. of 3 variables:
..$ values: int [1:6] 45 46 45 54 53 52
..$ phase : Factor w/ 2 levels "A","B": 1 1 1 2 2 2
..$ case : Factor w/ 2 levels "Hans","Wurst": 1 1 1 1 1 1
$ Wurst:'data.frame': 6 obs. of 3 variables:
..$ values: int [1:6] 45 46 45 54 53 52
..$ phase : Factor w/ 2 levels "A","B": 1 1 1 2 2 2
..$ case : Factor w/ 2 levels "Hans","Wurst": 2 2 2 2 2 2
attr(, "class")= chr [1:2] "scdf" "list"
attr(
, "scdf")=List of 3
..$ var.phase : chr "phase"
..$ var.values: chr "values"
..$ var.mt : chr "mt"
bsp-import.csv

Add CDC method

CDC is a common method to support VA of SC data. Build a function that applies these rules to a given scdf.

All Tau-U Meta Results for A vs. B return a Tau-U value of 1/-1 and an "-Inf" Z Value

Hello Juergen,

I hope you're well! I am writing to report a potentially serious bug in the latest version of the "Scan" package. In short, for the Tau-U meta analyses function, the "A vs B" model seems to only return a Tau-U value of 1/-1 and an "-Inf" z value. It returns these values even though some of the individual cases included within the meta-analyses have "A vs. B" values less than 1 or -1 (meaning that there should be no way that the overall Tau-U meta-analysis should have an "Inf" Z score). Furthermore, I just went back and updated some of my prior code to re-run it in the latest version of the scan package (version 0.59) and my results have changed and indeed the A vs. B contrast is now only showing a Tau-U value of 1/-1 and an "Inf" Z score. I would be grateful if you all can look into this as soon possible, as this seems to have a very serious impact on the analyses I am seeking to do at this time (and going forward) and now this test seems to contain some serious inaccuracies. Thank you so much!

Improve class definitions for scdf and sc

Here are some suggestions from the Hadley book Advanced R:

http://adv-r.had.co.nz/S3.html

Best practices

Create a construction method that checks the types of the input, and returns a list with the correct class label. XXX <- function(...) {}

Write a function to check if an object is of your class: is.XXX <- function(x) inherits(x, "XXX")

When implementing a vector class, you should implement these methods: length, [, [<-, [[, [[<-, c. (If [ is implemented rev, head, and tail should all work).

When implementing anything mathematical, implement Ops, Math and Summary.

When implementing a matrix/array class, you should implement these methods: dim (gets you nrow and ncol), t, dimnames (gets you rownames and colnames), dimnames<- (gets you colnames<-, rownames<-), cbind, rbind.

If you’re implementing more complicated print() methods, it’s a better idea to implement format() methods that return a string, and then implement print.class <- function(x, ...) cat(format(x, ...), "\n". This makes for methods that are much easier to compose, because the side-effects are isolated to a single place.

rounding error in "trendA_sm"

  1. Correct rounding error in split middle technique trend line for odd halfs.
  2. Rename ("trendA_bisplit") to better distinguish from other methods (e.g. tri-split) in the future.

Release scan 0.60.0

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • usethis::use_github_links()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

set_vars function does not work

Hello! I am reaching out because of a few issues/requested clarifications.

First, the set_vars function does not work at all for me, meaning I have to define all of the variables manually.

Posting a reproducible example below:

library(scan)
set_vars(exampleAB, 'values', 'mt','phase')

###This should work, but it returns the following error:

###Error in scdf_attr[[var]] <- value :
###attempt to select less than one element in OneIndex

alternating treatments

Hello! It is possible to use this package with alternating treatments data? The data seem to import ok, and all of the data points show up when using plot(). However, the describe() function shows the incorrect number of sessions for n.A and n.B, and the summary statistics are incorrect (I believe it's just summarizing the last instance(s) of A and the last instance(s) of B).

Tau-U Meta, Method "Complete" and Confidence Intervals Above 1

Discussed in #90

Originally posted by gjones1219 December 27, 2022
Hello again Jurgen! I hope you are taking good care. I had a quick question about the output for Tau-U meta.

In the "Jazz" book, it says that for Tau-U meta, method = "complete", values for for Tau-U output will range from [-1,1]. However, when one looks at the confidence intervals that are returned by the Tau-U meta function when using method = "complete", the values for the 95% Confidence Intervals are sometimes outside of this range (i.e., above and below [-1,1]). Please see the example in the scan book at this link: https://jazznbass.github.io/scan-Book/ch_overlapping_indices.html#tau-u (specifically, look at the output for the following line of code: tau_u(exampleAB) )

Can you please explain this discrepancy? Thanks so much!

Grant

Functional programming in scan

Add functions:

  • select_cases() [a basic structure is already in place in scan, but should be extended to select cases not just by name or number but by criteria from a level-2 dataset]
  • select_measurements() [e.g.: scdf %>% select_measurement(teacher_present == 1 & depression < 5) ]
  • select_variables() [e.g.: scdf %>% select_variables(values, mt, phase, depression)
  • select_phases() [e.g.: scdf %>% select_phases(A2, B2) ; scdf %>% select_phases(A = c("A1", "A2"), B = c("B1", "B2")]

Problem in plotSC function: overlap of case names and first data points at the top left

Hi Jürgen,

I have the problem that I want to plot a SCDA list with a total of three different features of one case with the plotSC function, but the case.names overlap at the top left with the first data points. This is unfortunately the case with all given styles and I haven't found out yet which function in the sytle.plotSC command I can use to put the case.names to the bottom of the graph.

I attach a screenshot of the issue:

scan_plot

I would like to change the position of the case.names to the down left. I could of course drop the output of the names via case.names"", but for designing a figure in a paper I would then have to laboriously reintegrate the names for each graph. That would be comparatively laborious and the image quality would suffer. I would prefer to change the position of the case.names to the down left. Maybe there is a solution in scan.

Many thanks and best regards

Gino

CRAN packages maintained by you

I got the following email. I took care of it, but did not upload a working package to cran:

Dear maintainers,

This concerns the CRAN packages

ACCLMA EasyMARK McSpatial aMNLFA aqp astrochron dMod dagitty ddsPLS
diffrprojects diffrprojectswidget dynsbm forestmangr gee4 goeveg
iCellR jmdl marindicators mcglm mpr outbreaker2 pmd pompom
promotionImpact qualityTools riverplot rmetalog rodham rtext scan
sentometrics slim smartdata spacetime stringb subtee tadaatoolbox
unga utiml varjmcm varrank

maintained by one of you:

Adriano Rivolli [email protected]: utiml
Alireza Khodadadi-Jamayran [email protected]: iCellR
Daniel Farewell [email protected]: slim
Daniel Kaschek [email protected]: dMod
Daniel McMillen [email protected]: McSpatial
Danielle Dempsey [email protected]: marindicators
Dylan Beaudette [email protected]: aqp
Edzer Pebesma [email protected]: spacetime
Finlay Campbell [email protected]: outbreaker2
Friedemann Goral [email protected]: goeveg
Gilles Kratzer [email protected]: varrank
Hadrien Lorenzo [email protected]: ddsPLS
Ignacio Cordón [email protected]: smartdata
Isaac Faber [email protected]: rmetalog
Jane Lee [email protected]: jmdl
January Weiner [email protected]: riverplot
Johannes Textor [email protected]: dagitty
John Coene [email protected]: rodham
John Waller [email protected]: EasyMARK
Juergen Wilbert [email protected]: scan
Kevin Burke [email protected]: mpr
Lukas Burk [email protected]: tadaatoolbox
Miao YU [email protected]: pmd
Nahyun Kim [email protected]: promotionImpact
Naimin Jing [email protected]: varjmcm
Nicolas Ballarini [email protected]: subtee
Peter Meissner [email protected]: diffrprojects
diffrprojectswidget rtext stringb
Peter Thuresson [email protected]: unga
Samuel Borms [email protected]: sentometrics
Sollano Rabelo Braga [email protected]: forestmangr
Stephen Meyers [email protected]: astrochron
Tal Carmi [email protected]: ACCLMA
Thomas Roth [email protected]: qualityTools
Veronica Cole [email protected]: aMNLFA
Vincent Miele [email protected]: dynsbm
Wagner Hugo Bonat [email protected]: mcglm
Xiao Yang [email protected]: pompom
Yi Pan [email protected]: gee4

As I already wrote one month ago:

You may have seen that when running your package code with current
r-devel, one gets warnings about

cannot xtfrm data frames

This is because you call order() on a data frame with k rows and 1
column which (currently) returns something of length k.

Now,

? sort says

 Sort (or _order_) a vector or factor (partially) into ascending or
 descending order.  For ordering along more than one variable,
 e.g., for sorting data frames, see ‘order’

where in turn ? order says

 ‘order’ returns a permutation which rearranges its first argument
 into ascending or descending order, breaking ties by further
 arguments.  ‘sort.list’ does the same, using only one argument.
 See the examples for how to use these functions to sort data
 frames, etc.

and then the examples clearly explain to use do.call() for data
frames, ideally also unnaming to avoid name clashes.

Can you please change your package code to no longer call order() on
data frames?

To easily identify the calls to be changed, you could setenv
R_STOP_ON_XTFRM_DATA_FRAME=true and use a current version of R-devel.

Note that this will be the final reminder.

Best
-k

new plot function with pipes

Our plot function is becoming more and more bloated.
I have redesigned a new approach which embraces a pipe structure and more straight forward functional programming (similar to ggplot). While keeping the previous plot function intact, i like to add it to v0.54 and gradually shift it to be the main approach. Here is an example of what it looks like:

scplot(exampleABAB) %>% 
  add_line("trendA", col = "red") %>%
  add_line("maxA", col = "lightblue") %>%
  add_marks(outlier(exampleABAB), col = "brown", cex = 2) %>%
  set_xaxis(increase = 4, label = "Weeks") %>%
  set_yaxis(lim = c(0, 50), label = "Points") %>%
  add_title("Points as a function of weeks") %>%
  set_case_names("MY", "FUNNY", "VALENTINE") %>%
  set_phase_names("Baseline", "Intervention", "Fall-Back", "Intervention") %>%
  add_style("grid2") %>%
  add_style("tiny") %>%
  add_style(fill.bg = "grey96")

image

beside the clear coding here are some more advantages:

  • putting the steps (drawing marks, lines, adding styles) into separate functions helps to implement future features much more easily
  • For the user, documentation is easier to find because each step can get its own help page
  • The return value is an object (class scdf_plot). The plot itself is generated, when the object is printed. This makes it easier to implement export functions for pdf, png etc.

Here is what the code for the above plot would look like with the current function:

plot(exampleABAB, 
     style = list(style = c("grid2", "tiny"), fill.bg = "grey96"),
     lines = list(list("trendA", col = "red"), list("maxA", col = "lightblue")),
     marks = list(positions = outlier(exampleABAB)$dropped.mt, col = "brown", cex = 2),
     xinc = 4, xlab = "Weeks",
     ylim = c(0,50), ylab = "Points",
     main = "Points as a function of weeks",
     case.names = c("MY", "FUNNY", "VALENTINE"),
     phase.names = c("Baseline", "Intervention", "Fall-Back", "Intervention") 
)

@researchtool What do you think?

CRAN packages with sprintf warnings in R-devel

I got this email in October 2020. I took care of it, but did not upload a working package to cran yet.

That is

CodeDepends DescTools FluMoDL GmAMisc LOGICOIL ODB Publish
R.utils anytime aos aroma.core assertive.datetimes colt dbmss dbstats
doFuture easyDes ecespa ems fastJT fun future future.BatchJobs
future.apply future.batchtools future.callr geojsonio ggedit globals
highlight huxtable jtGWAS jwutil knitLatex ldaPrototype lfe listenv
logmult matlib meteR mlr mlrMBO move munsellinterpol nets
nvmix odin openxlsx parallelly pkgmaker plfMA pomp progressr rdlocrand
rioja salso scan sjstats smacpod spatialEco spatialsegregation
spatstat stablelearner sybil tcpl tinyProject tinytest tryCatchLog
tsdecomp vetr xgboost

R-devel has a new runtime check in sprintf() that all arguments are used
by the format and this is showing one or more warnings in the checks of
these packages, usually in the examples. E.g.

Warning in sprintf("%s$", extension, ignore.case = TRUE) :
argument not used by format
Warning in sprintf("%s", getFunctionLinks(tokens[w]),
tokens[w], :
argument not used by format

Please investigate (by running R CMD check with the latest R-devel and
grepping the .Rcheck directory). In some cases the warning seems to be
from another package, usually one with the same maintainer. If from one
not on this list, please let CRAN and its maintainer know. If you think
this is a false positive, please contact Tomas Kalibera (in Cc:).

--
Brian D. Ripley, [email protected]
Emeritus Professor of Applied Statistics, University of Oxford

`select_case()`

Instead of relying on subsetting [] and $ scan should become more userfriendly and compatible with pipes %>%.
Therefore, select_case() could provide easy and advanceded selection of cases by number, name or further criteria.

Release scan 0.59.0

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Check if any deprecation processes should be advanced, as described in Gradual deprecation
  • Polish NEWS
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • git push
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.