Compare commits

...

8 Commits

Author SHA1 Message Date
f04322a9db Created ROSALI screening version 2025-02-13 15:24:10 +01:00
7712f8396f Few changes in R code 2025-01-15 10:51:52 +01:00
7f1a9ad455 Update to article code 2024-10-17 17:23:10 +02:00
185111cbed Licensed data 2024-06-06 15:59:50 +02:00
99368b23c4 Updated supplementaries 2024-06-06 15:04:54 +02:00
68849b3170 Added article supplementary materials 2024-06-06 14:34:39 +02:00
1a13f09889 Update README 2024-06-04 11:34:57 +02:00
827f73e380 LICENSE 2024-06-04 11:34:24 +02:00
16 changed files with 10643 additions and 584 deletions

2
.gitignore vendored
View File

@ -9,3 +9,5 @@
!res_dat_dif_rosali.csv !res_dat_dif_rosali.csv
!res_dat_dif_resali.csv !res_dat_dif_resali.csv
*.dcf *.dcf
*.pdf
*.png

232
DATA_LICENSE Normal file
View File

@ -0,0 +1,232 @@
Preamble
The Open Database License (ODbL) is a license agreement intended to allow users to freely share, modify, and use this Database while maintaining this same freedom for others. Many databases are covered by copyright, and therefore this document licenses these rights. Some jurisdictions, mainly in the European Union, have specific rights that cover databases, and so the ODbL addresses these rights, too. Finally, the ODbL is also an agreement in contract for users of this Database to act in certain ways in return for accessing this Database.
Databases can contain a wide variety of types of content (images, audiovisual material, and sounds all in the same database, for example), and so the ODbL only governs the rights over the Database, and not the contents of the Database individually. Licensors should use the ODbL together with another license for the contents, if the contents have a single set of rights that uniformly covers all of the contents. If the contents have multiple sets of different rights, Licensors should describe what rights govern what contents together in the individual record or in some other way that clarifies what rights apply.
Sometimes the contents of a database, or the database itself, can be covered by other rights not addressed here (such as private contracts, trade mark over the name, or privacy rights / data protection rights over information in the contents), and so you are advised that you may have to consult other documents or clear other rights before doing activities not covered by this License.
The Licensor (as defined below)
and
You (as defined below)
agree as follows:
1.0 Definitions of Capitalised Words
“Collective Database” Means this Database in unmodified form as part of a collection of independent databases in themselves that together are assembled into a collective whole. A work that constitutes a Collective Database will not be considered a Derivative Database.
“Convey” As a verb, means Using the Database, a Derivative Database, or the Database as part of a Collective Database in any way that enables a Person to make or receive copies of the Database or a Derivative Database. Conveying does not include interaction with a user through a computer network, or creating and Using a Produced Work, where no transfer of a copy of the Database or a Derivative Database occurs. “Contents” The contents of this Database, which includes the information, independent works, or other material collected into the Database. For example, the contents of the Database could be factual data or works such as images, audiovisual material, text, or sounds.
“Database” A collection of material (the Contents) arranged in a systematic or methodical way and individually accessible by electronic or other means offered under the terms of this License.
“Database Directive” Means Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended or succeeded.
“Database Right” Means rights resulting from the Chapter III (“sui generis”) rights in the Database Directive (as amended and as transposed by member states), which includes the Extraction and Re-utilisation of the whole or a Substantial part of the Contents, as well as any similar rights available in the relevant jurisdiction under Section 10.4.
“Derivative Database” Means a database based upon the Database, and includes any translation, adaptation, arrangement, modification, or any other alteration of the Database or of a Substantial part of the Contents. This includes, but is not limited to, Extracting or Re-utilising the whole or a Substantial part of the Contents in a new Database.
“Extraction” Means the permanent or temporary transfer of all or a Substantial part of the Contents to another medium by any means or in any form.
“License” Means this license agreement and is both a license of rights such as copyright and Database Rights and an agreement in contract.
“Licensor” Means the Person that offers the Database under the terms of this License.
“Person” Means a natural or legal person or a body of persons corporate or incorporate.
“Produced Work” a work (such as an image, audiovisual material, text, or sounds) resulting from using the whole or a Substantial part of the Contents (via a search or other query) from this Database, a Derivative Database, or this Database as part of a Collective Database.
“Publicly” means to Persons other than You or under Your control by either more than 50% ownership or by the power to direct their activities (such as contracting with an independent consultant).
“Re-utilisation” means any form of making available to the public all or a Substantial part of the Contents by the distribution of copies, by renting, by online or other forms of transmission.
“Substantial” Means substantial in terms of quantity or quality or a combination of both. The repeated and systematic Extraction or Re-utilisation of insubstantial parts of the Contents may amount to the Extraction or Re-utilisation of a Substantial part of the Contents.
“Use” As a verb, means doing any act that is restricted by copyright or Database Rights whether in the original medium or any other; and includes without limitation distributing, copying, publicly performing, publicly displaying, and preparing derivative works of the Database, as well as modifying the Database as may be technically necessary to use it in a different mode or format.
“You” Means a Person exercising rights under this License who has not previously violated the terms of this License with respect to the Database, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
Words in the singular include the plural and vice versa.
2.0 What this License covers
2.1. Legal effect of this document. This License is:
a. A license of applicable copyright and neighbouring rights;
b. A license of the Database Right; and
c. An agreement in contract between You and the Licensor.
2.2 Legal rights covered. This License covers the legal rights in the Database, including:
a. Copyright. Any copyright or neighbouring rights in the Database. The copyright licensed includes any individual elements of the Database, but does not cover the copyright over the Contents independent of this Database. See Section 2.4 for details. Copyright law varies between jurisdictions, but is likely to cover: the Database model or schema, which is the structure, arrangement, and organisation of the Database, and can also include the Database tables and table indexes; the data entry and output sheets; and the Field names of Contents stored in the Database;
b. Database Rights. Database Rights only extend to the Extraction and Re-utilisation of the whole or a Substantial part of the Contents. Database Rights can apply even when there is no copyright over the Database. Database Rights can also apply when the Contents are removed from the Database and are selected and arranged in a way that would not infringe any applicable copyright; and
c. Contract. This is an agreement between You and the Licensor for access to the Database. In return you agree to certain conditions of use on this access as outlined in this License.
2.3 Rights not covered.
a. This License does not apply to computer programs used in the making or operation of the Database;
b. This License does not cover any patents over the Contents or the Database; and
c. This License does not cover any trademarks associated with the Database.
2.4 Relationship to Contents in the Database. The individual items of the Contents contained in this Database may be covered by other rights, including copyright, patent, data protection, privacy, or personality rights, and this License does not cover any rights (other than Database Rights or in contract) in individual Contents contained in the Database. For example, if used on a Database of images (the Contents), this License would not apply to copyright over individual images, which could have their own separate licenses, or one single license covering all of the rights over the images.
3.0 Rights granted
3.1 Subject to the terms and conditions of this License, the Licensor grants to You a worldwide, royalty-free, non-exclusive, terminable (but only under Section 9) license to Use the Database for the duration of any applicable copyright and Database Rights. These rights explicitly include commercial use, and do not exclude any field of endeavour. To the extent possible in the relevant jurisdiction, these rights may be exercised in all media and formats whether now known or created in the future.
The rights granted cover, for example:
a. Extraction and Re-utilisation of the whole or a Substantial part of the Contents;
b. Creation of Derivative Databases;
c. Creation of Collective Databases;
d. Creation of temporary or permanent reproductions by any means and in any form, in whole or in part, including of any Derivative Databases or as a part of Collective Databases; and
e. Distribution, communication, display, lending, making available, or performance to the public by any means and in any form, in whole or in part, including of any Derivative Database or as a part of Collective Databases.
3.2 Compulsory license schemes. For the avoidance of doubt:
a. Non-waivable compulsory license schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
b. Waivable compulsory license schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and,
c. Voluntary license schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License.
3.3 The right to release the Database under different terms, or to stop distributing or making available the Database, is reserved. Note that this Database may be multiple-licensed, and so You may have the choice of using alternative licenses for this Database. Subject to Section 10.4, all other rights not expressly granted by Licensor are reserved.
4.0 Conditions of Use
4.1 The rights granted in Section 3 above are expressly made subject to Your complying with the following conditions of use. These are important conditions of this License, and if You fail to follow them, You will be in material breach of its terms.
4.2 Notices. If You Publicly Convey this Database, any Derivative Database, or the Database as part of a Collective Database, then You must:
a. Do so only under the terms of this License or another license permitted under Section 4.4;
b. Include a copy of this License (or, as applicable, a license permitted under Section 4.4) or its Uniform Resource Identifier (URI) with the Database or Derivative Database, including both in the Database or Derivative Database and in any relevant documentation; and
c. Keep intact any copyright or Database Right notices and notices that refer to this License.
d. If it is not possible to put the required notices in a particular file due to its structure, then You must include the notices in a location (such as a relevant directory) where users would be likely to look for it.
4.3 Notice for using output (Contents). Creating and Using a Produced Work does not require the notice in Section 4.2. However, if you Publicly Use a Produced Work, You must include a notice associated with the Produced Work reasonably calculated to make any Person that uses, views, accesses, interacts with, or is otherwise exposed to the Produced Work aware that Content was obtained from the Database, Derivative Database, or the Database as part of a Collective Database, and that it is available under this License.
a. Example notice. The following text will satisfy notice under Section 4.3:
Contains information from DATABASE NAME, which is made available
here under the Open Database License (ODbL).
DATABASE NAME should be replaced with the name of the Database and a hyperlink to the URI of the Database. “Open Database License” should contain a hyperlink to the URI of the text of this License. If hyperlinks are not possible, You should include the plain text of the required URIs with the above notice.
4.4 Share alike.
a. Any Derivative Database that You Publicly Use must be only under the terms of:
i. This License;
ii. A later version of this License similar in spirit to this License; or
iii. A compatible license.
If You license the Derivative Database under one of the licenses mentioned in (iii), You must comply with the terms of that license.
b. For the avoidance of doubt, Extraction or Re-utilisation of the whole or a Substantial part of the Contents into a new database is a Derivative Database and must comply with Section 4.4.
c. Derivative Databases and Produced Works. A Derivative Database is Publicly Used and so must comply with Section 4.4. if a Produced Work created from the Derivative Database is Publicly Used.
d. Share Alike and additional Contents. For the avoidance of doubt, You must not add Contents to Derivative Databases under Section 4.4 a that are incompatible with the rights granted under this License.
e. Compatible licenses. Licensors may authorise a proxy to determine compatible licenses under Section 4.4 a iii. If they do so, the authorised proxys public statement of acceptance of a compatible license grants You permission to use the compatible license.
4.5 Limits of Share Alike. The requirements of Section 4.4 do not apply in the following:
a. For the avoidance of doubt, You are not required to license Collective Databases under this License if You incorporate this Database or a Derivative Database in the collection, but this License still applies to this Database or a Derivative Database as a part of the Collective Database;
b. Using this Database, a Derivative Database, or this Database as part of a Collective Database to create a Produced Work does not create a Derivative Database for purposes of Section 4.4; and
c. Use of a Derivative Database internally within an organisation is not to the public and therefore does not fall under the requirements of Section 4.4.
4.6 Access to Derivative Databases. If You Publicly Use a Derivative Database or a Produced Work from a Derivative Database, You must also offer to recipients of the Derivative Database or Produced Work a copy in a machine readable form of:
a. The entire Derivative Database; or
b. A file containing all of the alterations made to the Database or the method of making the alterations to the Database (such as an algorithm), including any additional Contents, that make up all the differences between the Database and the Derivative Database.
The Derivative Database (under a.) or alteration file (under b.) must be available at no more than a reasonable production cost for physical distributions and free of charge if distributed over the internet.
4.7 Technological measures and additional terms
a. This License does not allow You to impose (except subject to Section 4.7 b.) any terms or any technological measures on the Database, a Derivative Database, or the whole or a Substantial part of the Contents that alter or restrict the terms of this License, or any rights granted under it, or have the effect or intent of restricting the ability of any person to exercise those rights.
b. Parallel distribution. You may impose terms or technological measures on the Database, a Derivative Database, or the whole or a Substantial part of the Contents (a “Restricted Database”) in contravention of Section 4.74 a. only if You also make a copy of the Database or a Derivative Database available to the recipient of the Restricted Database:
i. That is available without additional fee;
ii. That is available in a medium that does not alter or restrict the terms of this License, or any rights granted under it, or have the effect or intent of restricting the ability of any person to exercise those rights (an “Unrestricted Database”); and
iii. The Unrestricted Database is at least as accessible to the recipient as a practical matter as the Restricted Database.
c. For the avoidance of doubt, You may place this Database or a Derivative Database in an authenticated environment, behind a password, or within a similar access control scheme provided that You do not alter or restrict the terms of this License or any rights granted under it or have the effect or intent of restricting the ability of any person to exercise those rights.
4.8 Licensing of others. You may not sublicense the Database. Each time You communicate the Database, the whole or Substantial part of the Contents, or any Derivative Database to anyone else in any way, the Licensor offers to the recipient a license to the Database on the same terms and conditions as this License. You are not responsible for enforcing compliance by third parties with this License, but You may enforce any rights that You have over a Derivative Database. You are solely responsible for any modifications of a Derivative Database made by You or another Person at Your direction. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License.
5.0 Moral rights
5.1 Moral rights. This section covers moral rights, including any rights to be identified as the author of the Database or to object to treatment that would otherwise prejudice the authors honour and reputation, or any other derogatory treatment:
a. For jurisdictions allowing waiver of moral rights, Licensor waives all moral rights that Licensor may have in the Database to the fullest extent possible by the law of the relevant jurisdiction under Section 10.4;
b. If waiver of moral rights under Section 5.1 a in the relevant jurisdiction is not possible, Licensor agrees not to assert any moral rights over the Database and waives all claims in moral rights to the fullest extent possible by the law of the relevant jurisdiction under Section 10.4; and
c. For jurisdictions not allowing waiver or an agreement not to assert moral rights under Section 5.1 a and b, the author may retain their moral rights over certain aspects of the Database.
Please note that some jurisdictions do not allow for the waiver of moral rights, and so moral rights may still subsist over the Database in some jurisdictions.
6.0 Fair dealing, Database exceptions, and other rights not affected
6.1 This License does not affect any rights that You or anyone else may independently have under any applicable law to make any use of this Database, including without limitation:
a. Exceptions to the Database Right including: Extraction of Contents from non-electronic Databases for private purposes, Extraction for purposes of illustration for teaching or scientific research, and Extraction or Re-utilisation for public security or an administrative or judicial procedure.
b. Fair dealing, fair use, or any other legally recognised limitation or exception to infringement of copyright or other applicable laws.
6.2 This License does not affect any rights of lawful users to Extract and Re-utilise insubstantial parts of the Contents, evaluated quantitatively or qualitatively, for any purposes whatsoever, including creating a Derivative Database (subject to other rights over the Contents, see Section 2.4). The repeated and systematic Extraction or Re-utilisation of insubstantial parts of the Contents may however amount to the Extraction or Re-utilisation of a Substantial part of the Contents.
7.0 Warranties and Disclaimer
7.1 The Database is licensed by the Licensor “as is” and without any warranty of any kind, either express, implied, or arising by statute, custom, course of dealing, or trade usage. Licensor specifically disclaims any and all implied warranties or conditions of title, non-infringement, accuracy or completeness, the presence or absence of errors, fitness for a particular purpose, merchantability, or otherwise. Some jurisdictions do not allow the exclusion of implied warranties, so this exclusion may not apply to You.
8.0 Limitation of liability
8.1 Subject to any liability that may not be excluded or limited by law, the Licensor is not liable for, and expressly excludes, all liability for loss or damage however and whenever caused to anyone by any use under this License, whether by You or by anyone else, and whether caused by any fault on the part of the Licensor or not. This exclusion of liability includes, but is not limited to, any special, incidental, consequential, punitive, or exemplary damages such as loss of revenue, data, anticipated profits, and lost business. This exclusion applies even if the Licensor has been advised of the possibility of such damages.
8.2 If liability may not be excluded by law, it is limited to actual and direct financial loss to the extent it is caused by proved negligence on the part of the Licensor.
9.0 Termination of Your rights under this License
9.1 Any breach by You of the terms and conditions of this License automatically terminates this License with immediate effect and without notice to You. For the avoidance of doubt, Persons who have received the Database, the whole or a Substantial part of the Contents, Derivative Databases, or the Database as part of a Collective Database from You under this License will not have their licenses terminated provided their use is in full compliance with this License or a license granted under Section 4.8 of this License. Sections 1, 2, 7, 8, 9 and 10 will survive any termination of this License.
9.2 If You are not in breach of the terms of this License, the Licensor will not terminate Your rights under it.
9.3 Unless terminated under Section 9.1, this License is granted to You for the duration of applicable rights in the Database.
9.4 Reinstatement of rights. If you cease any breach of the terms and conditions of this License, then your full rights under this License will be reinstated:
a. Provisionally and subject to permanent termination until the 60th day after cessation of breach;
b. Permanently on the 60th day after cessation of breach unless otherwise reasonably notified by the Licensor; or
c. Permanently if reasonably notified by the Licensor of the violation, this is the first time You have received notice of violation of this License from the Licensor, and You cure the violation prior to 30 days after your receipt of the notice.
Persons subject to permanent termination of rights are not eligible to be a recipient and receive a license under Section 4.8.
9.5 Notwithstanding the above, Licensor reserves the right to release the Database under different license terms or to stop distributing or making available the Database. Releasing the Database under different license terms or stopping the distribution of the Database will not withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
10.0 General
10.1 If any provision of this License is held to be invalid or unenforceable, that must not affect the validity or enforceability of the remainder of the terms and conditions of this License and each remaining provision of this License shall be valid and enforced to the fullest extent permitted by law.
10.2 This License is the entire agreement between the parties with respect to the rights granted here over the Database. It replaces any earlier understandings, agreements or representations with respect to the Database.
10.3 If You are in breach of the terms of this License, You will not be entitled to rely on the terms of this License or to complain of any breach by the Licensor.
10.4 Choice of law. This License takes effect in and will be governed by the laws of the relevant jurisdiction in which the License terms are sought to be enforced. If the standard suite of rights granted under applicable copyright law and Database Rights in the relevant jurisdiction includes additional rights not granted under this License, these additional rights are granted in this License in order to meet the terms of this License.

661
LICENSE Normal file
View File

@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
# Simulations # Simulations
This repository contains all code files related to our ROSALI/Resiuals RCT simulation project. In order to save disk space, data files are not stored on this server and are instead available on https://osf.io. This repository contains all code files related to our ROSALI/Resiuals RCT simulation project. In order to save disk space, data files are not stored on this server and are instead available on https://osf.io/zjtfe/
## File Structure ## File Structure

View File

@ -17,7 +17,7 @@ lastChar <- function(str){
substr(str, nchar(str), nchar(str)) substr(str, nchar(str), nchar(str))
} }
source(paste0(getwd(),"/functions/resali.R")) source(paste0(getwd(),"/Scripts/Analysis/functions/resali.R"))
############################################################################## ##############################################################################
#----------------------------------------------------------------------------# #----------------------------------------------------------------------------#
@ -147,13 +147,23 @@ replicate_pcm_analysis<- function(df=NULL,treatment='TT',irtmodel='PCM2',method=
#### Create data.frame #### Create data.frame
results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G')))) #results <- c(sapply(c(2,4),function(x) paste0(x,c('A','B','C'))),sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G')))) #results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x))) #results <- c(sapply(c(50,100,300),function(x) paste0(results,'_',x)))
results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x))) #results2 <- c(sapply(c(50,100,300),function(x) paste0(results2,'_',x)))
#results <- c(results,results2)
results <- c(sapply(c(2,4),function(x) paste0(x,c('A','B','C'))),sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(c("050",100,300),function(x) paste0(results,'_',x)))
results2 <- c(sapply(c("050",100,300),function(x) paste0(results2,'_',x)))
results <- sort(results) results <- sort(results)
@ -161,6 +171,11 @@ results2 <- sort(results2)
results <- c(results,results2) results <- c(results,results2)
results <- gsub('050',"50",results)
# results <- c(sapply(1:16,function(x) c(results[x],results[x+16],results[x+32])),
# sapply(1:30,function(x) c(results[x+48],results[x+30+48],results[x+60+48]))
# )
#### Compiler function #### Compiler function
compile_simulation <- function(scenario) { compile_simulation <- function(scenario) {
@ -216,6 +231,41 @@ compile_simulation <- function(scenario) {
} }
N <- ifelse(substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50","50",substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))) N <- ifelse(substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50","50",substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)))
zz <- ifelse(N=="50",substr(scenario,start=0,stop=nchar(scenario)-3),substr(scenario,start=0,stop=nchar(scenario)-4)) zz <- ifelse(N=="50",substr(scenario,start=0,stop=nchar(scenario)-3),substr(scenario,start=0,stop=nchar(scenario)-4))
zz.type <- substr(zz,start=nchar(zz),stop=nchar(zz))
if (unique(is.na(s$dif.size))) {
s$dif.size <- 0
}
if(zz=="10B") {
s$dif.size <- 0.3
}
if (substr(zz,1,1)%in%c("6","8")) {
s$nb.dif <- 1
}
if (substr(zz,1,2)%in%c("10","12","14",'16')) {
s$nb.dif <- 2
}
if (substr(zz,1,1)%in%c("18","20")) {
s$nb.dif <- 3
}
if (zz.type!="A") {
if (zz.type=="B") {
s$eff.size <- 0.2
} else if (zz.type=="C" & unique(s$dif.size)==0) {
s$eff.size <- 0.4
} else if (zz.type=="C" & unique(s$dif.size)!=0) {
s$eff.size <- 0.2
} else if (zz.type=="D" & unique(s$dif.size)!=0) {
s$eff.size <- 0.4
} else if (zz.type=="E" & unique(s$dif.size)!=0) {
s$eff.size <- 0.4
}
} else {
s$eff.size <- 0
s$dif.size <- -1*s$dif.size
}
b <- data.frame(scenario=zz, b <- data.frame(scenario=zz,
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)), scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
N=N, N=N,
@ -230,6 +280,7 @@ compile_simulation <- function(scenario) {
se.analytical.beta=mean(s$se.beta), se.analytical.beta=mean(s$se.beta),
m.low.ci.beta=mean(s$low.ci.beta), m.low.ci.beta=mean(s$low.ci.beta),
m.high.ci.beta=mean(s$high.ci.beta), m.high.ci.beta=mean(s$high.ci.beta),
bias=mean(s$beta-s$eff.size),
true.value.in.ci.p=mean(s$true.value.in.ci), true.value.in.ci.p=mean(s$true.value.in.ci),
h0.rejected.p=mean(s$h0.rejected), h0.rejected.p=mean(s$h0.rejected),
beta.same.sign.truebeta.p=mean(s$beta.same.sign.truebeta,na.rm=T), beta.same.sign.truebeta.p=mean(s$beta.same.sign.truebeta,na.rm=T),
@ -241,37 +292,22 @@ compile_simulation <- function(scenario) {
#### Compiled results #### Compiled results
res.dat <- compile_simulation('1A_100') res.dat <- compile_simulation('2A_50')
for (x in results[seq(2,length(results))]) { for (x in results[seq(2,length(results))]) {
y <- compile_simulation(x) y <- compile_simulation(x)
res.dat <- bind_rows(res.dat,y) res.dat <- bind_rows(res.dat,y)
} }
res.dat[res.dat$scenario.type=='A','dif.size'] <- -res.dat[res.dat$scenario.type=='A','dif.size']
res.dat[is.na(res.dat$dif.size),'dif.size'] <- 0
res.dat[193:417,'nb.dif'] <- 2
res.dat[417:528,'nb.dif'] <- 3
res.dat[res.dat$scenario.type=="B",]$eff.size <- 0.2
res.dat[res.dat$scenario.type=="C" & res.dat$dif.size==0,]$eff.size <- 0.4
res.dat[res.dat$scenario.type=="C" & res.dat$dif.size!=0,]$eff.size <- 0.2
res.dat[res.dat$scenario.type=="D" & res.dat$dif.size==0,]$eff.size <- -0.2
res.dat[res.dat$scenario.type=="D" & res.dat$dif.size!=0,]$eff.size <- 0.4
res.dat[res.dat$scenario.type=="E" & res.dat$dif.size==0,]$eff.size <- -0.4
res.dat[res.dat$scenario.type=="E" & res.dat$dif.size!=0,]$eff.size <- 0.4
res.dat[res.dat$scenario.type=="F",]$eff.size <- -0.2
res.dat[res.dat$scenario.type=="G",]$eff.size <- -0.4
View(res.dat)
res.dat.simple <- res.dat[,c(1:8,13,16:18)] res.dat[res.dat$N==50,"dif.size"] <- res.dat[which(res.dat$N==50)+1,"dif.size"]
res.dat.simple$m.beta <- round(res.dat.simple$m.beta,3)
res.dat.simple
is.nan.data.frame <- function(x)
is.nan.data.frame <- function(x) {
do.call(cbind, lapply(x, is.nan)) do.call(cbind, lapply(x, is.nan))
}
res.dat[is.nan(res.dat)] <- NA res.dat[is.nan(res.dat)] <- NA
res.dat$bias <- res.dat$eff.size-res.dat$m.beta
############################################################################## ##############################################################################
@ -282,19 +318,21 @@ res.dat$bias <- res.dat$eff.size-res.dat$m.beta
#### Create data.frame #### Create data.frame
results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G')))) results <- c(sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G')))) results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x))) results <- c(sapply(c("050",100,300),function(x) paste0(results,'_',x)))
results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x))) results2 <- c(sapply(c("050",100,300),function(x) paste0(results2,'_',x)))
results <- sort(results) results <- sort(results)
results2 <- sort(results2) results2 <- sort(results2)
results <- c(results,results2)[81:528] results <- c(results,results2)
results <- gsub('050',"50",results)
#### Compiler function #### Compiler function
@ -376,14 +414,23 @@ compile_simulation2 <- function(scenario) {
#### Compiled results #### Compiled results
res.dat.dif <- compile_simulation2('5A_100') res.dat.dif <- compile_simulation2('6A_50')
for (x in results[seq(2,length(results))]) { for (x in results[seq(2,length(results))]) {
y <- compile_simulation2(x) y <- compile_simulation2(x)
res.dat.dif <- bind_rows(res.dat.dif,y) res.dat.dif <- bind_rows(res.dat.dif,y)
} }
res.dat$bias <- res.dat$eff.size-res.dat$m.beta res.dat.dif[is.na(res.dat.dif$dif.size),'dif.size'] <- 0
res.dat.dif[substr(res.dat.dif$scenario,1,1)%in%c("6","8"),'nb.dif'] <- 1
res.dat.dif[substr(res.dat.dif$scenario,1,2)%in%seq(10,16,2),'nb.dif'] <- 2
res.dat.dif[substr(res.dat.dif$scenario,1,2)%in%seq(18,20,2),'nb.dif'] <- 3
res.dat.dif[res.dat.dif$N==50,"dif.size"] <- res.dat.dif[which(res.dat.dif$N==50)+1,"dif.size"]
res.dat.dif[res.dat.dif$scenario.type=="B",]$eff.size <- 0.2
res.dat.dif[res.dat.dif$scenario.type=="C" & res.dat.dif$dif.size!=0,]$eff.size <- 0.2
res.dat.dif[res.dat.dif$scenario.type=="D" & res.dat.dif$dif.size!=0,]$eff.size <- 0.4
res.dat.dif[res.dat.dif$scenario.type=="E" & res.dat.dif$dif.size!=0,]$eff.size <- 0.4
res.dat.dif[res.dat.dif$scenario=="10B",]$dif.size <- 0.3
res.dat.dif$bias <- res.dat.dif$eff.size-res.dat.dif$m.beta res.dat.dif$bias <- res.dat.dif$eff.size-res.dat.dif$m.beta
############################################################################## ##############################################################################
@ -394,13 +441,14 @@ res.dat.dif$bias <- res.dat.dif$eff.size-res.dat.dif$m.beta
#### Create data.frame #### Create data.frame
results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G')))) results <- c(sapply(c(2,4),function(x) paste0(x,c('A','B','C'))),sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x))) results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x))) results <- c(sapply(c("050",100,300),function(x) paste0(results,'_',x)))
results2 <- c(sapply(c("050",100,300),function(x) paste0(results2,'_',x)))
results <- sort(results) results <- sort(results)
@ -408,6 +456,8 @@ results2 <- sort(results2)
results <- c(results,results2) results <- c(results,results2)
results <- gsub('050',"50",results)
#### Compiler function #### Compiler function
@ -650,13 +700,33 @@ compile_simulation2_rosali <- function(scenario) {
#### Compiled results #### Compiled results
res.dat.dif.rosali <- compile_simulation2_rosali('1A_100') res.dat.dif.rosali <- compile_simulation2_rosali('2A_50')
for (x in results[seq(2,length(results))]) { for (x in results[seq(2,length(results))]) {
y <- compile_simulation2_rosali(x) y <- compile_simulation2_rosali(x)
res.dat.dif.rosali <- bind_rows(res.dat.dif.rosali,y) res.dat.dif.rosali <- bind_rows(res.dat.dif.rosali,y)
} }
res.dat.dif.rosali[res.dat.dif.rosali$scenario.type=='A','dif.size'] <- -res.dat.dif.rosali[res.dat.dif.rosali$scenario.type=='A','dif.size']
res.dat.dif.rosali[is.na(res.dat.dif.rosali$dif.size),'dif.size'] <- 0
res.dat.dif.rosali[substr(res.dat.dif.rosali$scenario,1,1)%in%c("6","8"),'nb.dif'] <- 1
res.dat.dif.rosali[substr(res.dat.dif.rosali$scenario,1,2)%in%seq(10,16,2),'nb.dif'] <- 2
res.dat.dif.rosali[substr(res.dat.dif.rosali$scenario,1,2)%in%seq(18,20,2),'nb.dif'] <- 3
res.dat.dif.rosali[res.dat.dif.rosali$N==50,"dif.size"] <- res.dat.dif.rosali[which(res.dat.dif.rosali$N==50)+1,"dif.size"]
res.dat.dif.rosali[res.dat.dif.rosali$scenario.type=="B",]$eff.size <- 0.2
res.dat.dif.rosali[res.dat.dif.rosali$scenario.type=="C" & res.dat.dif.rosali$dif.size==0,]$eff.size <- 0.4
res.dat.dif.rosali[res.dat.dif.rosali$scenario.type=="C" & res.dat.dif.rosali$dif.size!=0,]$eff.size <- 0.2
res.dat.dif.rosali[res.dat.dif.rosali$scenario.type=="D" & res.dat.dif.rosali$dif.size!=0,]$eff.size <- 0.4
res.dat.dif.rosali[res.dat.dif.rosali$scenario.type=="E" & res.dat.dif.rosali$dif.size!=0,]$eff.size <- 0.4
res.dat.dif.rosali[res.dat.dif.rosali$scenario=="10B",]$dif.size <- 0.3
is.nan.data.frame <- function(x) {
do.call(cbind, lapply(x, is.nan))
}
res.dat.dif.rosali[is.nan(res.dat.dif.rosali)] <- NA
res.dat.dif.rosali$bias <- res.dat.dif.rosali$eff.size-res.dat.dif.rosali$m.beta res.dat.dif.rosali$bias <- res.dat.dif.rosali$eff.size-res.dat.dif.rosali$m.beta
@ -668,13 +738,29 @@ res.dat.dif.rosali$bias <- res.dat.dif.rosali$eff.size-res.dat.dif.rosali$m.beta
#### Create data.frame #### Create data.frame
results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G')))) #results <- c(sapply(c(2,4),function(x) paste0(x,c('A','B','C'))),sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x))) #results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x))) #results <- c(sapply(c(50,100,300),function(x) paste0(results,'_',x)))
#results2 <- c(sapply(c(50,100,300),function(x) paste0(results2,'_',x)))
#results <- c(results,results2)
#results <- c(sapply(1:16,function(x) c(results[x],results[x+16],results[x+32])),
# sapply(1:30,function(x) c(results[x+48],results[x+30+48],results[x+60+48]))
#)
results <- c(sapply(c(2,4),function(x) paste0(x,c('A','B','C'))),sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(c("050",100,300),function(x) paste0(results,'_',x)))
results2 <- c(sapply(c("050",100,300),function(x) paste0(results2,'_',x)))
results <- sort(results) results <- sort(results)
@ -682,6 +768,8 @@ results2 <- sort(results2)
results <- c(results,results2) results <- c(results,results2)
results <- gsub('050',"50",results)
#### Compiler function #### Compiler function
@ -920,13 +1008,34 @@ compile_simulation2_resali <- function(scenario) {
#### Compiled results #### Compiled results
res.dat.dif.resali <- compile_simulation2_resali('1A_100') res.dat.dif.resali <- compile_simulation2_resali('2A_50')
for (x in results[seq(2,length(results))]) { for (x in results[seq(2,length(results))]) {
y <- compile_simulation2_resali(x) y <- compile_simulation2_resali(x)
res.dat.dif.resali <- bind_rows(res.dat.dif.resali,y) res.dat.dif.resali <- bind_rows(res.dat.dif.resali,y)
} }
res.dat.dif.resali[res.dat.dif.resali$scenario.type=='A','dif.size'] <- -res.dat.dif.resali[res.dat.dif.resali$scenario.type=='A','dif.size']
res.dat.dif.resali[is.na(res.dat.dif.resali$dif.size),'dif.size'] <- 0
res.dat.dif.resali[substr(res.dat.dif.resali$scenario,1,1)%in%c("6","8"),'nb.dif'] <- 1
res.dat.dif.resali[substr(res.dat.dif.resali$scenario,1,2)%in%seq(10,16,2),'nb.dif'] <- 2
res.dat.dif.resali[substr(res.dat.dif.resali$scenario,1,2)%in%seq(18,20,2),'nb.dif'] <- 3
res.dat.dif.resali[res.dat.dif.resali$N==50,"dif.size"] <- res.dat.dif.resali[which(res.dat.dif.resali$N==50)+1,"dif.size"]
res.dat.dif.resali[res.dat.dif.resali$scenario.type=="B",]$eff.size <- 0.2
res.dat.dif.resali[res.dat.dif.resali$scenario=="20E" & res.dat.dif.resali$N==50,]$dif.size <- -0.5
res.dat.dif.resali[res.dat.dif.resali$scenario.type=="C" & res.dat.dif.resali$dif.size==0,]$eff.size <- 0.4
res.dat.dif.resali[res.dat.dif.resali$scenario.type=="C" & res.dat.dif.resali$dif.size!=0,]$eff.size <- 0.2
res.dat.dif.resali[res.dat.dif.resali$scenario.type=="D" & res.dat.dif.resali$dif.size!=0,]$eff.size <- 0.4
res.dat.dif.resali[res.dat.dif.resali$scenario.type=="E" & res.dat.dif.resali$dif.size!=0,]$eff.size <- 0.4
res.dat.dif.resali[res.dat.dif.resali$scenario=="10B",]$dif.size <- 0.3
is.nan.data.frame <- function(x) {
do.call(cbind, lapply(x, is.nan))
}
res.dat.dif.resali[is.nan(res.dat.dif.resali)] <- NA
res.dat.dif.resali$bias <- res.dat.dif.resali$eff.size-res.dat.dif.resali$m.beta res.dat.dif.resali$bias <- res.dat.dif.resali$eff.size-res.dat.dif.resali$m.beta
@ -943,20 +1052,6 @@ res.dat$theoretical.power <- 0
### Scénarios N=100 ### Scénarios N=100
## Scénarios J=4 / M=2
res.dat[res.dat$scenario %in% paste0(c(1,5,7,9,11),'A') & res.dat$N==100,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(1,5,7,9,11),'B') & res.dat$N==100,]$theoretical.power <- 0.1543
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'C') & res.dat$N==100,]$theoretical.power <- 0.1543
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'D') & res.dat$N==100,]$theoretical.power <- 0.4627
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'E') & res.dat$N==100,]$theoretical.power <- 0.4627
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'F') & res.dat$N==100,]$theoretical.power <- 0.1543
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'G') & res.dat$N==100,]$theoretical.power <- 0.4627
res.dat[res.dat$scenario %in% paste0(1,'C') & res.dat$N==100,]$theoretical.power <- 0.4627
res.dat[res.dat$scenario %in% paste0(1,'D') & res.dat$N==100,]$theoretical.power <- 0.1543
res.dat[res.dat$scenario %in% paste0(1,'E') & res.dat$N==100,]$theoretical.power <- 0.4627
## Scénarios J=4 / M=4 ## Scénarios J=4 / M=4
res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'A') & res.dat$N==100,]$theoretical.power <- 0.05 res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'A') & res.dat$N==100,]$theoretical.power <- 0.05
@ -964,26 +1059,8 @@ res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'B') & res.dat$N==100,]$theo
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'C') & res.dat$N==100,]$theoretical.power <- 0.2177 res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'C') & res.dat$N==100,]$theoretical.power <- 0.2177
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'D') & res.dat$N==100,]$theoretical.power <- 0.6586 res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'D') & res.dat$N==100,]$theoretical.power <- 0.6586
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'E') & res.dat$N==100,]$theoretical.power <- 0.6586 res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'E') & res.dat$N==100,]$theoretical.power <- 0.6586
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'F') & res.dat$N==100,]$theoretical.power <- 0.2177
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'G') & res.dat$N==100,]$theoretical.power <- 0.6586
res.dat[res.dat$scenario %in% paste0(2,'C') & res.dat$N==100,]$theoretical.power <- 0.6586 res.dat[res.dat$scenario %in% paste0(2,'C') & res.dat$N==100,]$theoretical.power <- 0.6586
res.dat[res.dat$scenario %in% paste0(2,'D') & res.dat$N==100,]$theoretical.power <- 0.2177
res.dat[res.dat$scenario %in% paste0(2,'E') & res.dat$N==100,]$theoretical.power <- 0.6586
## Scénarios J=7 / M=2
res.dat[res.dat$scenario %in% paste0(c(3,13,15,17,19),'A') & res.dat$N==100,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(3,13,15,17,19),'B') & res.dat$N==100,]$theoretical.power <- 0.1870
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'C') & res.dat$N==100,]$theoretical.power <- 0.1870
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'D') & res.dat$N==100,]$theoretical.power <- 0.5666
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'E') & res.dat$N==100,]$theoretical.power <- 0.5666
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'F') & res.dat$N==100,]$theoretical.power <- 0.1870
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'G') & res.dat$N==100,]$theoretical.power <- 0.5666
res.dat[res.dat$scenario %in% paste0(3,'C') & res.dat$N==100,]$theoretical.power <- 0.5666
res.dat[res.dat$scenario %in% paste0(3,'D') & res.dat$N==100,]$theoretical.power <- 0.1870
res.dat[res.dat$scenario %in% paste0(3,'E') & res.dat$N==100,]$theoretical.power <- 0.5666
## Scénarios J=7 / M=4 ## Scénarios J=7 / M=4
@ -992,91 +1069,13 @@ res.dat[res.dat$scenario %in% paste0(c(4,14,16,18,20),'B') & res.dat$N==100,]$th
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'C') & res.dat$N==100,]$theoretical.power <- 0.2450 res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'C') & res.dat$N==100,]$theoretical.power <- 0.2450
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'D') & res.dat$N==100,]$theoretical.power <- 0.7136 res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'D') & res.dat$N==100,]$theoretical.power <- 0.7136
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'E') & res.dat$N==100,]$theoretical.power <- 0.7136 res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'E') & res.dat$N==100,]$theoretical.power <- 0.7136
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'F') & res.dat$N==100,]$theoretical.power <- 0.2450
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'G') & res.dat$N==100,]$theoretical.power <- 0.7136
res.dat[res.dat$scenario %in% paste0(4,'C') & res.dat$N==100,]$theoretical.power <- 0.7136 res.dat[res.dat$scenario %in% paste0(4,'C') & res.dat$N==100,]$theoretical.power <- 0.7136
res.dat[res.dat$scenario %in% paste0(4,'D') & res.dat$N==100,]$theoretical.power <- 0.2450
res.dat[res.dat$scenario %in% paste0(4,'E') & res.dat$N==100,]$theoretical.power <- 0.7136
### Scénarios N=200
## Scénarios J=4 / M=2
res.dat[res.dat$scenario %in% paste0(c(1,5,7,9,11),'A') & res.dat$N==200,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(1,5,7,9,11),'B') & res.dat$N==200,]$theoretical.power <- 0.2618
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'C') & res.dat$N==200,]$theoretical.power <- 0.2618
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'D') & res.dat$N==200,]$theoretical.power <- 0.7507
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'E') & res.dat$N==200,]$theoretical.power <- 0.7507
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'F') & res.dat$N==200,]$theoretical.power <- 0.2618
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'G') & res.dat$N==200,]$theoretical.power <- 0.7507
res.dat[res.dat$scenario %in% paste0(1,'C') & res.dat$N==200,]$theoretical.power <- 0.7507
res.dat[res.dat$scenario %in% paste0(1,'D') & res.dat$N==200,]$theoretical.power <- 0.2618
res.dat[res.dat$scenario %in% paste0(1,'E') & res.dat$N==200,]$theoretical.power <- 0.7507
## Scénarios J=4 / M=4
res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'A') & res.dat$N==200,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'B') & res.dat$N==200,]$theoretical.power <- 0.3875
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'C') & res.dat$N==200,]$theoretical.power <- 0.3875
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'D') & res.dat$N==200,]$theoretical.power <- 0.9161
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'E') & res.dat$N==200,]$theoretical.power <- 0.9161
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'F') & res.dat$N==200,]$theoretical.power <- 0.3875
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'G') & res.dat$N==200,]$theoretical.power <- 0.9161
res.dat[res.dat$scenario %in% paste0(2,'C') & res.dat$N==200,]$theoretical.power <- 0.9161
res.dat[res.dat$scenario %in% paste0(2,'D') & res.dat$N==200,]$theoretical.power <- 0.3875
res.dat[res.dat$scenario %in% paste0(2,'E') & res.dat$N==200,]$theoretical.power <- 0.9161
## Scénarios J=7 / M=2
res.dat[res.dat$scenario %in% paste0(c(3,13,15,17,19),'A') & res.dat$N==200,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(3,13,15,17,19),'B') & res.dat$N==200,]$theoretical.power <- 0.3258
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'C') & res.dat$N==200,]$theoretical.power <- 0.3258
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'D') & res.dat$N==200,]$theoretical.power <- 0.8538
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'E') & res.dat$N==200,]$theoretical.power <- 0.8538
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'F') & res.dat$N==200,]$theoretical.power <- 0.3258
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'G') & res.dat$N==200,]$theoretical.power <- 0.8538
res.dat[res.dat$scenario %in% paste0(3,'C') & res.dat$N==200,]$theoretical.power <- 0.8538
res.dat[res.dat$scenario %in% paste0(3,'D') & res.dat$N==200,]$theoretical.power <- 0.3258
res.dat[res.dat$scenario %in% paste0(3,'E') & res.dat$N==200,]$theoretical.power <- 0.8538
## Scénarios J=7 / M=4
res.dat[res.dat$scenario %in% paste0(c(4,14,16,18,20),'A') & res.dat$N==200,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(4,14,16,18,20),'B') & res.dat$N==200,]$theoretical.power <- 0.4321
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'C') & res.dat$N==200,]$theoretical.power <- 0.4321
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'D') & res.dat$N==200,]$theoretical.power <- 0.9471
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'E') & res.dat$N==200,]$theoretical.power <- 0.9471
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'F') & res.dat$N==200,]$theoretical.power <- 0.4321
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'G') & res.dat$N==200,]$theoretical.power <- 0.9471
res.dat[res.dat$scenario %in% paste0(4,'C') & res.dat$N==200,]$theoretical.power <- 0.9471
res.dat[res.dat$scenario %in% paste0(4,'D') & res.dat$N==200,]$theoretical.power <- 0.4321
res.dat[res.dat$scenario %in% paste0(4,'E') & res.dat$N==200,]$theoretical.power <- 0.9471
### Scénarios N=300 ### Scénarios N=300
## Scénarios J=4 / M=2
res.dat[res.dat$scenario %in% paste0(c(1,5,7,9,11),'A') & res.dat$N==300,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(1,5,7,9,11),'B') & res.dat$N==300,]$theoretical.power <- 0.3660
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'C') & res.dat$N==300,]$theoretical.power <- 0.3660
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'D') & res.dat$N==300,]$theoretical.power <- 0.8981
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'E') & res.dat$N==300,]$theoretical.power <- 0.8981
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'F') & res.dat$N==300,]$theoretical.power <- 0.3660
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'G') & res.dat$N==300,]$theoretical.power <- 0.8981
res.dat[res.dat$scenario %in% paste0(1,'C') & res.dat$N==300,]$theoretical.power <- 0.8981
res.dat[res.dat$scenario %in% paste0(1,'D') & res.dat$N==300,]$theoretical.power <- 0.3660
res.dat[res.dat$scenario %in% paste0(1,'E') & res.dat$N==300,]$theoretical.power <- 0.8981
## Scénarios J=4 / M=4 ## Scénarios J=4 / M=4
res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'A') & res.dat$N==300,]$theoretical.power <- 0.05 res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'A') & res.dat$N==300,]$theoretical.power <- 0.05
@ -1084,26 +1083,8 @@ res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'B') & res.dat$N==300,]$theo
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'C') & res.dat$N==300,]$theoretical.power <- 0.5373 res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'C') & res.dat$N==300,]$theoretical.power <- 0.5373
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'D') & res.dat$N==300,]$theoretical.power <- 0.9834 res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'D') & res.dat$N==300,]$theoretical.power <- 0.9834
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'E') & res.dat$N==300,]$theoretical.power <- 0.9834 res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'E') & res.dat$N==300,]$theoretical.power <- 0.9834
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'F') & res.dat$N==300,]$theoretical.power <- 0.5373
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'G') & res.dat$N==300,]$theoretical.power <- 0.9834
res.dat[res.dat$scenario %in% paste0(2,'C') & res.dat$N==300,]$theoretical.power <- 0.9834 res.dat[res.dat$scenario %in% paste0(2,'C') & res.dat$N==300,]$theoretical.power <- 0.9834
res.dat[res.dat$scenario %in% paste0(2,'D') & res.dat$N==300,]$theoretical.power <- 0.5373
res.dat[res.dat$scenario %in% paste0(2,'E') & res.dat$N==300,]$theoretical.power <- 0.9834
## Scénarios J=7 / M=2
res.dat[res.dat$scenario %in% paste0(c(3,13,15,17,19),'A') & res.dat$N==300,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(3,13,15,17,19),'B') & res.dat$N==300,]$theoretical.power <- 0.4550
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'C') & res.dat$N==300,]$theoretical.power <- 0.4550
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'D') & res.dat$N==300,]$theoretical.power <- 0.9584
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'E') & res.dat$N==300,]$theoretical.power <- 0.9584
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'F') & res.dat$N==300,]$theoretical.power <- 0.4550
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'G') & res.dat$N==300,]$theoretical.power <- 0.9584
res.dat[res.dat$scenario %in% paste0(3,'C') & res.dat$N==300,]$theoretical.power <- 0.9584
res.dat[res.dat$scenario %in% paste0(3,'D') & res.dat$N==300,]$theoretical.power <- 0.4550
res.dat[res.dat$scenario %in% paste0(3,'E') & res.dat$N==300,]$theoretical.power <- 0.9584
## Scénarios J=7 / M=4 ## Scénarios J=7 / M=4
@ -1112,30 +1093,12 @@ res.dat[res.dat$scenario %in% paste0(c(4,14,16,18,20),'B') & res.dat$N==300,]$th
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'C') & res.dat$N==300,]$theoretical.power <- 0.5907 res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'C') & res.dat$N==300,]$theoretical.power <- 0.5907
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'D') & res.dat$N==300,]$theoretical.power <- 0.9919 res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'D') & res.dat$N==300,]$theoretical.power <- 0.9919
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'E') & res.dat$N==300,]$theoretical.power <- 0.9919 res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'E') & res.dat$N==300,]$theoretical.power <- 0.9919
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'F') & res.dat$N==300,]$theoretical.power <- 0.5907
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'G') & res.dat$N==300,]$theoretical.power <- 0.9919
res.dat[res.dat$scenario %in% paste0(4,'C') & res.dat$N==300,]$theoretical.power <- 0.9919 res.dat[res.dat$scenario %in% paste0(4,'C') & res.dat$N==300,]$theoretical.power <- 0.9919
res.dat[res.dat$scenario %in% paste0(4,'D') & res.dat$N==300,]$theoretical.power <- 0.5907
res.dat[res.dat$scenario %in% paste0(4,'E') & res.dat$N==300,]$theoretical.power <- 0.9919
### Scénarios N=50 ### Scénarios N=50
## Scénarios J=4 / M=2
res.dat[res.dat$scenario %in% paste0(c(1,5,7,9,11),'A') & res.dat$N==50,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(1,5,7,9,11),'B') & res.dat$N==50,]$theoretical.power <- 0.1013
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'C') & res.dat$N==50,]$theoretical.power <- 0.1013
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'D') & res.dat$N==50,]$theoretical.power <- 0.2615
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'E') & res.dat$N==50,]$theoretical.power <- 0.2615
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'F') & res.dat$N==50,]$theoretical.power <- 0.1013
res.dat[res.dat$scenario %in% paste0(c(5,7,9,11),'G') & res.dat$N==50,]$theoretical.power <- 0.2615
res.dat[res.dat$scenario %in% paste0(1,'C') & res.dat$N==50,]$theoretical.power <- 0.2615
res.dat[res.dat$scenario %in% paste0(1,'D') & res.dat$N==50,]$theoretical.power <- 0.1013
res.dat[res.dat$scenario %in% paste0(1,'E') & res.dat$N==50,]$theoretical.power <- 0.2615
## Scénarios J=4 / M=4 ## Scénarios J=4 / M=4
res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'A') & res.dat$N==50,]$theoretical.power <- 0.05 res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'A') & res.dat$N==50,]$theoretical.power <- 0.05
@ -1143,26 +1106,8 @@ res.dat[res.dat$scenario %in% paste0(c(2,6,8,10,12),'B') & res.dat$N==50,]$theor
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'C') & res.dat$N==50,]$theoretical.power <- 0.1339 res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'C') & res.dat$N==50,]$theoretical.power <- 0.1339
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'D') & res.dat$N==50,]$theoretical.power <- 0.3863 res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'D') & res.dat$N==50,]$theoretical.power <- 0.3863
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'E') & res.dat$N==50,]$theoretical.power <- 0.3863 res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'E') & res.dat$N==50,]$theoretical.power <- 0.3863
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'F') & res.dat$N==50,]$theoretical.power <- 0.1339
res.dat[res.dat$scenario %in% paste0(c(6,8,10,12),'G') & res.dat$N==50,]$theoretical.power <- 0.3863
res.dat[res.dat$scenario %in% paste0(2,'C') & res.dat$N==50,]$theoretical.power <- 0.3863 res.dat[res.dat$scenario %in% paste0(2,'C') & res.dat$N==50,]$theoretical.power <- 0.3863
res.dat[res.dat$scenario %in% paste0(2,'D') & res.dat$N==50,]$theoretical.power <- 0.1339
res.dat[res.dat$scenario %in% paste0(2,'E') & res.dat$N==50,]$theoretical.power <- 0.3863
## Scénarios J=7 / M=2
res.dat[res.dat$scenario %in% paste0(c(3,13,15,17,19),'A') & res.dat$N==50,]$theoretical.power <- 0.05
res.dat[res.dat$scenario %in% paste0(c(3,13,15,17,19),'B') & res.dat$N==50,]$theoretical.power <- 0.1171
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'C') & res.dat$N==50,]$theoretical.power <- 0.1171
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'D') & res.dat$N==50,]$theoretical.power <- 0.3236
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'E') & res.dat$N==50,]$theoretical.power <- 0.3236
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'F') & res.dat$N==50,]$theoretical.power <- 0.1171
res.dat[res.dat$scenario %in% paste0(c(13,15,17,19),'G') & res.dat$N==50,]$theoretical.power <- 0.3236
res.dat[res.dat$scenario %in% paste0(3,'C') & res.dat$N==50,]$theoretical.power <- 0.3236
res.dat[res.dat$scenario %in% paste0(3,'D') & res.dat$N==50,]$theoretical.power <- 0.1171
res.dat[res.dat$scenario %in% paste0(3,'E') & res.dat$N==50,]$theoretical.power <- 0.3236
## Scénarios J=7 / M=4 ## Scénarios J=7 / M=4
@ -1171,17 +1116,12 @@ res.dat[res.dat$scenario %in% paste0(c(4,14,16,18,20),'B') & res.dat$N==50,]$the
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'C') & res.dat$N==50,]$theoretical.power <- 0.1448 res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'C') & res.dat$N==50,]$theoretical.power <- 0.1448
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'D') & res.dat$N==50,]$theoretical.power <- 0.4328 res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'D') & res.dat$N==50,]$theoretical.power <- 0.4328
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'E') & res.dat$N==50,]$theoretical.power <- 0.4328 res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'E') & res.dat$N==50,]$theoretical.power <- 0.4328
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'F') & res.dat$N==50,]$theoretical.power <- 0.1448
res.dat[res.dat$scenario %in% paste0(c(14,16,18,20),'G') & res.dat$N==50,]$theoretical.power <- 0.4328
res.dat[res.dat$scenario %in% paste0(4,'C') & res.dat$N==50,]$theoretical.power <- 0.4328 res.dat[res.dat$scenario %in% paste0(4,'C') & res.dat$N==50,]$theoretical.power <- 0.4328
res.dat[res.dat$scenario %in% paste0(4,'D') & res.dat$N==50,]$theoretical.power <- 0.1448
res.dat[res.dat$scenario %in% paste0(4,'E') & res.dat$N==50,]$theoretical.power <- 0.4328
### DIF scenarios ### DIF scenarios
res.dat.dif$theoretical.power <- res.dat[81:nrow(res.dat),]$theoretical.power res.dat.dif$theoretical.power <- res.dat[res.dat$dif.size!=0,]$theoretical.power
res.dat.dif.rosali$theoretical.power <- res.dat$theoretical.power res.dat.dif.rosali$theoretical.power <- res.dat$theoretical.power
res.dat.dif.resali$theoretical.power <- res.dat$theoretical.power res.dat.dif.resali$theoretical.power <- res.dat$theoretical.power
@ -1200,37 +1140,180 @@ res.dat.dif.rosali$method <- "ROSALI"
res.dat.dif.resali$method <- "RESIDUS" res.dat.dif.resali$method <- "RESIDUS"
# Correction of N=50 scenarios
res.dat[res.dat$N==50,]$dif.size <- sapply(which(res.dat$N==50),function(k) res.dat[k-1,]$dif.size)
res.dat.dif[res.dat.dif$N==50,]$dif.size <- sapply(which(res.dat.dif$N==50),function(k) res.dat.dif[k-1,]$dif.size)
res.dat.dif.rosali[res.dat.dif.rosali$N==50,]$dif.size <- sapply(which(res.dat.dif.rosali$N==50),function(k) res.dat.dif.rosali[k-1,]$dif.size)
res.dat.dif.resali[res.dat.dif.resali$N==50,]$dif.size <- sapply(which(res.dat.dif.resali$N==50),function(k) res.dat.dif.resali[k-1,]$dif.size)
res.dat[res.dat$dif.size!=0 & res.dat$nb.dif==0,]$nb.dif <- 1
res.dat.dif <- res.dat.dif %>%
relocate(method, .after = theoretical.power)
res.dat[res.dat$scenario=="10B",]$dif.size <- 0.3
res.dat.dif[res.dat.dif$scenario=="10B",]$dif.size <- 0.3
res.dat.dif.rosali[res.dat.dif.rosali$scenario=="10B",]$dif.size <- 0.3
res.dat.dif.resali[res.dat.dif.resali$scenario=="10B",]$dif.size <- 0.3
res.dat.dif[res.dat.dif$N=="50" & res.dat.dif$nb.dif>0,]$eff.size <- rep(c(0,0.2,0.2,0.4,0.4,-0.2,-0.4),16)
res.dat.dif[res.dat.dif$N=="50" & res.dat.dif$nb.dif>0 & res.dat.dif$scenario.type=="C",]$bias <- res.dat.dif[res.dat.dif$N=="50" & res.dat.dif$nb.dif>0 & res.dat.dif$scenario.type=="C",]$bias -0.2
res.dat.dif[res.dat.dif$N=="50" & res.dat.dif$nb.dif>0 & res.dat.dif$scenario.type=="D",]$bias <- res.dat.dif[res.dat.dif$N=="50" & res.dat.dif$nb.dif>0 & res.dat.dif$scenario.type=="D",]$bias +0.6
res.dat.dif[res.dat.dif$N=="50" & res.dat.dif$nb.dif>0 & res.dat.dif$scenario.type=="E",]$bias <- res.dat.dif[res.dat.dif$N=="50" & res.dat.dif$nb.dif>0 & res.dat.dif$scenario.type=="E",]$bias +0.8
res.dat[res.dat$N=="50" & res.dat$nb.dif>0,]$eff.size <- rep(c(0,0.2,0.2,0.4,0.4,-0.2,-0.4),16)
res.dat[res.dat$N=="50" & res.dat$nb.dif>0 & res.dat$scenario.type=="C",]$bias <- res.dat[res.dat$N=="50" & res.dat$nb.dif>0 & res.dat$scenario.type=="C",]$bias -0.2
res.dat[res.dat$N=="50" & res.dat$nb.dif>0 & res.dat$scenario.type=="D",]$bias <- res.dat[res.dat$N=="50" & res.dat$nb.dif>0 & res.dat$scenario.type=="D",]$bias +0.6
res.dat[res.dat$N=="50" & res.dat$nb.dif>0 & res.dat$scenario.type=="E",]$bias <- res.dat[res.dat$N=="50" & res.dat$nb.dif>0 & res.dat$scenario.type=="E",]$bias +0.8
res.dat.dicho <- res.dat[res.dat$M==2,]
res.dat.dicho <- rbind(res.dat.dicho,res.dat.dif[res.dat.dif$M==2,])
res.dat.dicho <- rbind.fill(res.dat.dicho,res.dat.dif.rosali[res.dat.dif.rosali$M==2,])
res.dat.dicho <- rbind.fill(res.dat.dicho,res.dat.dif.resali[res.dat.dif.resali$M==2,])
# Items polytomiques # Items polytomiques
res.dat.poly <- res.dat[res.dat$M==4,] res.dat.full <- res.dat[res.dat$M==4,]
res.dat.poly <- rbind(res.dat.poly,res.dat.dif[res.dat.dif$M==4,]) res.dat.full <- rbind(res.dat.full,res.dat.dif[res.dat.dif$M==4,])
res.dat.poly <- rbind.fill(res.dat.poly,res.dat.dif.rosali[res.dat.dif.rosali$M==4,]) res.dat.full <- rbind.fill(res.dat.full,res.dat.dif.rosali[res.dat.dif.rosali$M==4,])
res.dat.poly <- rbind.fill(res.dat.poly,res.dat.dif.resali[res.dat.dif.resali$M==4,]) res.dat.full <- rbind.fill(res.dat.full,res.dat.dif.resali[res.dat.dif.resali$M==4,])
##############################################################################
#----------------------------------------------------------------------------#
############################ ARTICLE TABLE OUTPUT ############################
#----------------------------------------------------------------------------#
##############################################################################
# STRATEGY 1 - IGNORE DIF
res.dat.article <- res.dat[,c("N","J","eff.size","nb.dif","dif.size",
"m.beta","bias","true.value.in.ci.p","h0.rejected.p",
"theoretical.power")]
colnames(res.dat.article)[3] <- "true.beta"
colnames(res.dat.article)[5] <- "true.gamma"
colnames(res.dat.article)[6] <- "betahat"
colnames(res.dat.article)[8] <- "coverage"
colnames(res.dat.article)[9] <- "power"
res.dat.article[,6:10] <- round(res.dat.article[,6:10],2)
res.dat.article[res.dat.article$true.beta==0,"typeIerror"] <- res.dat.article[res.dat.article$true.beta==0,"power"]
res.dat.article[res.dat.article$true.beta==0,"power"] <- NA
res.dat.article <- res.dat.article[,c(1:7,11,9:10,8)]
res.dat.article[res.dat.article$nb.dif==0,"true.gamma"] <- NA
res.dat.article[is.na(res.dat.article)] <- " "
res.dat.article$bias <- -1*res.dat.article$bias
res.dat.article.ignore <- reshape(res.dat.article[res.dat.article$nb.dif>0,],
direction = "wide", idvar = c("J","true.beta","nb.dif",'true.gamma'),timevar = "N" )
write.csv(res.dat.article.ignore,"/home/corentin/Documents/These/Valorisation/Articles/Simulations 1/Tables/res_ignoreDIF.csv")
res.dat.article.nodif.long <- res.dat.article[res.dat.article$nb.dif==0,]
res.dat.article.nodif <- reshape(res.dat.article[res.dat.article$nb.dif==0,],
direction = "wide", idvar = c("J","true.beta","nb.dif",'true.gamma'),timevar = "N" )
write.csv(res.dat.article.nodif,"/home/corentin/Documents/These/Valorisation/Articles/Simulations 1/Tables/res_noDIF.csv")
res.dat.article <- reshape(res.dat.article[res.dat.article$nb.dif==0,],
direction = "wide", idvar = c("J","true.beta","nb.dif",'true.gamma'),timevar = "N" )
write.csv(res.dat.article.nodif,"/home/corentin/Documents/These/Valorisation/Articles/Simulations 1/Tables/res_noDIF.csv")
res.dat.article.2 <- res.dat[,c("N","J","eff.size","nb.dif","dif.size",
"m.beta","bias","true.value.in.ci.p","h0.rejected.p",
"theoretical.power")]
colnames(res.dat.article.2)[3] <- "true.beta"
colnames(res.dat.article.2)[5] <- "true.gamma"
colnames(res.dat.article.2)[6] <- "betahat"
colnames(res.dat.article.2)[8] <- "coverage"
colnames(res.dat.article.2)[9] <- "power"
res.dat.article.2[,6:10] <- round(res.dat.article.2[,6:10],2)
res.dat.article.2[res.dat.article.2$true.beta==0,"typeIerror"] <- res.dat.article.2[res.dat.article.2$true.beta==0,"power"]
res.dat.article.2[res.dat.article.2$true.beta==0,"power"] <- NA
res.dat.article.2 <- res.dat.article.2[,c(1:7,11,9:10,8)]
res.dat.article.2[res.dat.article.2$nb.dif==0,"true.gamma"] <- NA
res.dat.article.2[is.na(res.dat.article.2)] <- " "
res.dat.article.2$bias <- -1*res.dat.article.2$bias
res.dat.article.nodif.2 <- res.dat.article.2[res.dat.article.2$nb.dif==0,]
# STRATEGY 2 - ROSALI
res.dat.article.rosali <- res.dat.dif.rosali[,c("N","J","eff.size","nb.dif","dif.size",
"m.beta","bias","true.value.in.ci.p","h0.rejected.p",
"theoretical.power")]
colnames(res.dat.article.rosali)[3] <- "true.beta"
colnames(res.dat.article.rosali)[5] <- "true.gamma"
colnames(res.dat.article.rosali)[6] <- "betahat"
colnames(res.dat.article.rosali)[8] <- "coverage"
colnames(res.dat.article.rosali)[9] <- "power"
res.dat.article.rosali[res.dat.article.rosali$true.beta==0,"typeIerror"] <- res.dat.article.rosali[res.dat.article.rosali$true.beta==0,"power"]
res.dat.article.rosali[res.dat.article.rosali$true.beta==0,"power"] <- NA
res.dat.article.rosali <- res.dat.article.rosali[,c(1:7,11,9:10,8)]
res.dat.article.rosali[res.dat.article.rosali$nb.dif==0,"true.gamma"] <- NA
res.dat.article.rosali[is.na(res.dat.article.rosali)] <- " "
res.dat.article.rosali$bias <- -1*res.dat.article.rosali$bias
res.dat.article.rosali <- reshape(res.dat.article.rosali,
direction = "wide", idvar = c("J","true.beta","nb.dif",'true.gamma'),timevar = "N" )
res.dat.article.rosali.dif <- res.dat.article.rosali[res.dat.article.rosali$nb.dif>0,]
write.csv(res.dat.article.rosali.dif,"/home/corentin/Documents/These/Valorisation/Articles/Simulations 1/Tables/res_ROSALI_DIF.csv")
res.dat.article.rosali.nodif <- res.dat.article.rosali[res.dat.article.rosali$nb.dif==0,]
write.csv(res.dat.article.rosali.nodif,"/home/corentin/Documents/These/Valorisation/Articles/Simulations 1/Tables/res_ROSALI_noDIF.csv")
res.dat.article.rosali.2 <- res.dat.dif.rosali[,c("N","J","eff.size","nb.dif","dif.size",
"m.beta","bias","true.value.in.ci.p","h0.rejected.p",
"theoretical.power")]
colnames(res.dat.article.rosali.2)[3] <- "true.beta"
colnames(res.dat.article.rosali.2)[5] <- "true.gamma"
colnames(res.dat.article.rosali.2)[6] <- "betahat"
colnames(res.dat.article.rosali.2)[8] <- "coverage"
colnames(res.dat.article.rosali.2)[9] <- "power"
res.dat.article.rosali.2[res.dat.article.rosali.2$true.beta==0,"typeIerror"] <- res.dat.article.rosali.2[res.dat.article.rosali.2$true.beta==0,"power"]
res.dat.article.rosali.2[res.dat.article.rosali.2$true.beta==0,"power"] <- NA
res.dat.article.rosali.2 <- res.dat.article.rosali.2[,c(1:7,11,9:10,8)]
res.dat.article.rosali.2[res.dat.article.rosali.2$nb.dif==0,"true.gamma"] <- NA
res.dat.article.rosali.2[is.na(res.dat.article.rosali.2)] <- " "
res.dat.article.rosali.2$bias <- -1*res.dat.article.rosali.2$bias
res.dat.article.rosali.2.nodif <- res.dat.article.rosali.2[res.dat.article.rosali.2$nb.dif==0,]
# STRATEGY 3 - RESIDIF
res.dat.dif.resali[1,"N"] <- 50
res.dat.dif.resali$dif.size <- res.dat.dif.rosali$dif.size
res.dat.article.residif <- res.dat.dif.resali[,c("N","J","eff.size","nb.dif","dif.size",
"m.beta","bias","true.value.in.ci.p","h0.rejected.p",
"theoretical.power")]
colnames(res.dat.article.residif)[3] <- "true.beta"
colnames(res.dat.article.residif)[5] <- "true.gamma"
colnames(res.dat.article.residif)[6] <- "betahat"
colnames(res.dat.article.residif)[8] <- "coverage"
colnames(res.dat.article.residif)[9] <- "power"
res.dat.article.residif[res.dat.article.residif$true.beta==0,"typeIerror"] <- res.dat.article.residif[res.dat.article.residif$true.beta==0,"power"]
res.dat.article.residif[res.dat.article.residif$true.beta==0,"power"] <- NA
res.dat.article.residif <- res.dat.article.residif[,c(1:7,11,9:10,8)]
res.dat.article.residif[res.dat.article.residif$nb.dif==0,"true.gamma"] <- NA
res.dat.article.residif[is.na(res.dat.article.residif)] <- " "
res.dat.article.residif$bias <- -1*res.dat.article.residif$bias
res.dat.article.residif <- reshape(res.dat.article.residif,
direction = "wide", idvar = c("J","true.beta","nb.dif",'true.gamma'),timevar = "N")
res.dat.article.residif.dif <- res.dat.article.residif[res.dat.article.residif$nb.dif>0,]
write.csv(res.dat.article.residif.dif,"/home/corentin/Documents/These/Valorisation/Articles/Simulations 1/Tables/res_RESIDIF_DIF.csv")
res.dat.article.residif.nodif <- res.dat.article.residif[res.dat.article.residif$nb.dif==0,]
write.csv(res.dat.article.residif.nodif,"/home/corentin/Documents/These/Valorisation/Articles/Simulations 1/Tables/res_RESIDIF_noDIF.csv")
res.dat.article.residif.2 <- res.dat.dif.resali[,c("N","J","eff.size","nb.dif","dif.size",
"m.beta","bias","true.value.in.ci.p","h0.rejected.p",
"theoretical.power")]
colnames(res.dat.article.residif.2)[3] <- "true.beta"
colnames(res.dat.article.residif.2)[5] <- "true.gamma"
colnames(res.dat.article.residif.2)[6] <- "betahat"
colnames(res.dat.article.residif.2)[8] <- "coverage"
colnames(res.dat.article.residif.2)[9] <- "power"
res.dat.article.residif.2[res.dat.article.residif.2$true.beta==0,"typeIerror"] <- res.dat.article.residif.2[res.dat.article.residif.2$true.beta==0,"power"]
res.dat.article.residif.2[res.dat.article.residif.2$true.beta==0,"power"] <- NA
res.dat.article.residif.2 <- res.dat.article.residif.2[,c(1:7,11,9:10,8)]
res.dat.article.residif.2[res.dat.article.residif.2$nb.dif==0,"true.gamma"] <- NA
res.dat.article.residif.2[is.na(res.dat.article.residif.2)] <- " "
res.dat.article.residif.2$bias <- -1*res.dat.article.residif.2$bias
res.dat.article.residif.2.nodif <- res.dat.article.residif.2[res.dat.article.residif.2$nb.dif==0,]
res.dat.article.residif.dif
# STRATEGY 4 - PERFECT-DIF
res.dat.article.dif <- res.dat.dif[,c("N","J","eff.size","nb.dif","dif.size",
"m.beta","bias","true.value.in.ci.p","h0.rejected.p",
"theoretical.power")]
colnames(res.dat.article.dif)[3] <- "true.beta"
colnames(res.dat.article.dif)[5] <- "true.gamma"
colnames(res.dat.article.dif)[6] <- "betahat"
colnames(res.dat.article.dif)[8] <- "coverage"
colnames(res.dat.article.dif)[9] <- "power"
res.dat.article.dif[res.dat.article.dif$true.beta==0,"typeIerror"] <- res.dat.article.dif[res.dat.article.dif$true.beta==0,"power"]
res.dat.article.dif[res.dat.article.dif$true.beta==0,"power"] <- NA
res.dat.article.dif <- res.dat.article.dif[,c(1:7,11,9:10,8)]
res.dat.article.dif[res.dat.article.dif$nb.dif==0,"true.gamma"] <- NA
res.dat.article.dif[is.na(res.dat.article.dif)] <- " "
res.dat.article.dif$bias <- -1*res.dat.article.dif$bias
write.csv(res.dat.article.dif,"/home/corentin/Documents/These/Valorisation/Articles/Simulations 1/Tables/res_perfect.csv")
res.dat.article.dif <- reshape(res.dat.article.dif,
direction = "wide", idvar = c("J","true.beta","nb.dif",'true.gamma'),timevar = "N" )
write.csv(res.dat.article.dif,"/home/corentin/Documents/These/Valorisation/Articles/Simulations 1/Tables/res_perfect.csv")
res.dat.article.dif.2 <- res.dat.dif[,c("N","J","eff.size","nb.dif","dif.size",
"m.beta","bias","true.value.in.ci.p","h0.rejected.p",
"theoretical.power")]
colnames(res.dat.article.dif.2)[3] <- "true.beta"
colnames(res.dat.article.dif.2)[5] <- "true.gamma"
colnames(res.dat.article.dif.2)[6] <- "betahat"
colnames(res.dat.article.dif.2)[8] <- "coverage"
colnames(res.dat.article.dif.2)[9] <- "power"
res.dat.article.dif.2[res.dat.article.dif.2$true.beta==0,"typeIerror"] <- res.dat.article.dif.2[res.dat.article.dif.2$true.beta==0,"power"]
res.dat.article.dif.2[res.dat.article.dif.2$true.beta==0,"power"] <- NA
res.dat.article.dif.2 <- res.dat.article.dif.2[,c(1:7,11,9:10,8)]
res.dat.article.dif.2[res.dat.article.dif.2$nb.dif==0,"true.gamma"] <- NA
res.dat.article.dif.2[is.na(res.dat.article.dif.2)] <- " "
res.dat.article.dif.2$bias <- -1*res.dat.article.dif.2$bias

File diff suppressed because it is too large Load Diff

View File

@ -27,8 +27,8 @@ resali <- function(df=NULL,items=NULL,group=NULL,verbose=T) {
for (i in items) { for (i in items) {
dat[,paste0('res_',i)] <- IRT.residuals(pcm_initial)$stand_residuals[,i] dat[,paste0('res_',i)] <- IRT.residuals(pcm_initial)$stand_residuals[,i]
res.anova[i] <- summary(aov(dat[,paste0('res_',i)]~TT*score_q5,data=dat)) res.anova[i] <- summary(aov(dat[,paste0('res_',i)]~TT*score_q5,data=dat))
pval[i] <- res.anova[[i]][1,"Pr(>F)"] pval[c(i,i+nbitems)] <- c(res.anova[[i]][1,"Pr(>F)"],res.anova[[i]][3,"Pr(>F)"])
fval[i] <- res.anova[[i]][1,'F value'] fval[c(i,i+nbitems)] <- c(res.anova[[i]][1,'F value'],res.anova[[i]][3,"F value"])
} }
if (verbose) { if (verbose) {
cat('DONE\n') cat('DONE\n')
@ -43,9 +43,10 @@ resali <- function(df=NULL,items=NULL,group=NULL,verbose=T) {
cat(paste('COMPUTING STEP',k,'\n')) cat(paste('COMPUTING STEP',k,'\n'))
cat('-----------------------------------------------------------\n') cat('-----------------------------------------------------------\n')
} }
res.item <- gsub("[a-z]", "",colnames(resp)[which.max(fval)]) numitem <- ifelse(which.max(fval)%%(length(fval)/2)!=0,which.max(fval)%%(length(fval)/2),length(fval)/2)
res.item <- gsub("[a-z]", "",colnames(resp)[numitem])
res.items <- c(res.items,res.item) res.items <- c(res.items,res.item)
res.uni <- res.anova[[which.max(fval)]][3,"Pr(>F)"]>0.05 res.uni <- res.anova[[numitem]][3,"Pr(>F)"]>0.05
res.uniform <- c(res.uniform,res.uni) res.uniform <- c(res.uniform,res.uni)
items_n <- c(items_n[items_n!=paste0('item',res.item)],paste0("item",res.item,c("noTT","TT"))) items_n <- c(items_n[items_n!=paste0('item',res.item)],paste0("item",res.item,c("noTT","TT")))
dat[dat$TT==1,paste0("item",res.item,'TT')] <- dat[dat$TT==1,paste0('item',res.item)] dat[dat$TT==1,paste0("item",res.item,'TT')] <- dat[dat$TT==1,paste0('item',res.item)]
@ -53,24 +54,19 @@ resali <- function(df=NULL,items=NULL,group=NULL,verbose=T) {
resp <- dat[,items_n] resp <- dat[,items_n]
grp <- dat[,group] grp <- dat[,group]
pcm_while <- TAM::tam.mml(resp=resp,Y=grp,irtmodel = "PCM",est.variance = T,verbose=F) pcm_while <- TAM::tam.mml(resp=resp,Y=grp,irtmodel = "PCM",est.variance = T,verbose=F)
nbitems <- length(items_n) nbitems <- length(items_n)-2*length(res.items)
res.anova <- rep(NA,nbitems) res.anova <- rep(NA,nbitems)
pval <- rep(NA,nbitems) pval <- rep(NA,2*nbitems)
fval <- rep(NA,nbitems) fval <- rep(NA,2*nbitems)
for (i in 1:nbitems) { for (i in 1:nbitems) {
dat[,paste0('res_',i)] <- IRT.residuals(pcm_while)$stand_residuals[,i] dat[,paste0('res_',i)] <- IRT.residuals(pcm_while)$stand_residuals[,i]
res.anova[i] <- summary(aov(dat[,paste0('res_',i)]~TT*score_q5,data=dat)) res.anova[i] <- summary(aov(dat[,paste0('res_',i)]~TT*score_q5,data=dat))
pval[i] <- res.anova[[i]][1,"Pr(>F)"] pval[i] <- res.anova[[i]][1,"Pr(>F)"]
pval[i+nbitems] <- res.anova[[i]][3,"Pr(>F)"]
fval[i] <- res.anova[[i]][1,'F value'] fval[i] <- res.anova[[i]][1,'F value']
fval[i+nbitems] <- res.anova[[i]][3,"F value"]
} }
zz <- 0 zz <- 0
for (name_i in items_n) {
zz <- zz+1
if (grepl("TT",name_i)) {
pval[zz] <- 1
fval[zz] <- 0
}
}
if (verbose) { if (verbose) {
cat('DONE\n') cat('DONE\n')
cat('-----------------------------------------------------------\n') cat('-----------------------------------------------------------\n')

View File

@ -0,0 +1,167 @@
library(TAM)
resali <- function(df=NULL,items=NULL,group=NULL,verbose=T) {
if (verbose) {
cat('-----------------------------------------------------------\n')
cat('COMPUTING INITIAL PCM\n')
cat('-----------------------------------------------------------\n')
}
nbitems <- length(items)
nbitems_o <- nbitems
items_n <- paste0('item',items)
resp <- df[,items_n]
grp <- df[,group]
pcm_initial <- TAM::tam.mml(resp=resp,Y=grp,irtmodel = "PCM",est.variance = T,verbose=F)
dat <- df
dat$score <- rowSums(dat[,items_n])
nqt <- ifelse(length(unique(quantile(dat$score,seq(0,1,0.2))))==6,5,length(unique(quantile(dat$score,seq(0,1,0.2))))-1)
while (length(unique(quantile(dat$score,seq(0,1,1/nqt))))!=nqt+1) {
nqt <- nqt-1
}
# ITEM POLYTOMIQUE
if (max(resp)>1) {
dat$score_q5 <- cut(dat$score,unique(quantile(dat$score,seq(0,1,1/nqt))),labels=1:nqt,include.lowest=T)
res.anova <- rep(NA,nbitems)
pval <- rep(NA,nbitems)
fval <- rep(NA,nbitems)
for (i in items) {
dat[,paste0('res_',i)] <- IRT.residuals(pcm_initial)$stand_residuals[,i]
res.anova[i] <- summary(aov(dat[,paste0('res_',i)]~TT*score_q5,data=dat))
pval[i] <- res.anova[[i]][1,"Pr(>F)"]
fval[i] <- res.anova[[i]][1,'F value']
}
print(res.anova)
if (verbose) {
cat('DONE\n')
cat('-----------------------------------------------------------\n')
}
res.items <- c()
res.uniform <- c()
k <- 1
while(any(pval<0.05/(nbitems_o*3))) {
k <- k+1
if (verbose) {
cat(paste('COMPUTING STEP',k,'\n'))
cat('-----------------------------------------------------------\n')
}
res.item <- gsub("[a-z]", "",colnames(resp)[which.max(fval)])
res.items <- c(res.items,res.item)
res.uni <- res.anova[[which.max(fval)]][3,"Pr(>F)"]>0.05
res.uniform <- c(res.uniform,res.uni)
items_n <- c(items_n[items_n!=paste0('item',res.item)],paste0("item",res.item,c("noTT","TT")))
dat[dat$TT==1,paste0("item",res.item,'TT')] <- dat[dat$TT==1,paste0('item',res.item)]
dat[dat$TT==0,paste0("item",res.item,'noTT')] <- dat[dat$TT==0,paste0('item',res.item)]
resp <- dat[,items_n]
grp <- dat[,group]
pcm_while <- TAM::tam.mml(resp=resp,Y=grp,irtmodel = "PCM",est.variance = T,verbose=F)
nbitems <- length(items_n)
res.anova <- rep(NA,nbitems)
pval <- rep(NA,nbitems)
fval <- rep(NA,nbitems)
for (i in 1:nbitems) {
dat[,paste0('res_',i)] <- IRT.residuals(pcm_while)$stand_residuals[,i]
res.anova[i] <- summary(aov(dat[,paste0('res_',i)]~TT*score_q5,data=dat))
pval[i] <- res.anova[[i]][1,"Pr(>F)"]
fval[i] <- res.anova[[i]][1,'F value']
}
zz <- 0
for (name_i in items_n) {
zz <- zz+1
if (grepl("TT",name_i)) {
pval[zz] <- 1
fval[zz] <- 0
}
}
if (verbose) {
cat('DONE\n')
cat('-----------------------------------------------------------\n')
}
}
if (verbose) {
cat("DETECTED DIF ITEMS\n")
cat('-----------------------------------------------------------\n')
}
if (length(res.items>0)) {
results <- data.frame(dif.items=res.items,
uniform=1*res.uniform)
return(results)
}
else {
if (verbose) {
cat("No DIF was detected\n")
}
return(NULL)
}
# ITEM DICHOTOMIQUE
} else {
res.anova <- rep(NA,nbitems)
pval <- rep(NA,nbitems)
fval <- rep(NA,nbitems)
for (i in items) {
dat[,paste0('res_',i)] <- IRT.residuals(pcm_initial)$stand_residuals[,i]
res.anova[i] <- summary(aov(dat[,paste0('res_',i)]~TT,data=dat))
pval[i] <- res.anova[[i]][1,"Pr(>F)"]
fval[i] <- res.anova[[i]][1,'F value']
}
if (verbose) {
cat('DONE\n')
cat('-----------------------------------------------------------\n')
}
res.items <- c()
k <- 1
while(any(pval<0.05/(nbitems_o))) {
k <- k+1
if (verbose) {
cat(paste('COMPUTING STEP',k,'\n'))
cat('-----------------------------------------------------------\n')
}
res.item <- gsub("[a-z]", "",colnames(resp)[which.max(fval)])
res.items <- c(res.items,res.item)
items_n <- c(items_n[items_n!=paste0('item',res.item)],paste0("item",res.item,c("noTT","TT")))
dat[dat$TT==1,paste0("item",res.item,'TT')] <- dat[dat$TT==1,paste0('item',res.item)]
dat[dat$TT==0,paste0("item",res.item,'noTT')] <- dat[dat$TT==0,paste0('item',res.item)]
resp <- dat[,items_n]
grp <- dat[,group]
pcm_while <- TAM::tam.mml(resp=resp,Y=grp,irtmodel = "PCM",est.variance = T,verbose=F)
nbitems <- length(items_n)
res.anova <- rep(NA,nbitems)
pval <- rep(NA,nbitems)
fval <- rep(NA,nbitems)
for (i in 1:nbitems) {
dat[,paste0('res_',i)] <- IRT.residuals(pcm_while)$stand_residuals[,i]
res.anova[i] <- summary(aov(dat[,paste0('res_',i)]~TT,data=dat))
pval[i] <- res.anova[[i]][1,"Pr(>F)"]
fval[i] <- res.anova[[i]][1,'F value']
}
zz <- 0
for (name_i in items_n) {
zz <- zz+1
if (grepl("TT",name_i)) {
pval[zz] <- 1
fval[zz] <- 0
}
}
if (verbose) {
cat('DONE\n')
cat('-----------------------------------------------------------\n')
}
}
if (verbose) {
cat("DETECTED DIF ITEMS\n")
cat('-----------------------------------------------------------\n')
}
if (length(res.items>0)) {
results <- data.frame(dif.items=res.items,
uniform=rep(1,length(res.items)))
return(results)
}
else {
if (verbose) {
cat("No DIF was detected\n")
}
return(NULL)
}
}
}

View File

@ -4,7 +4,7 @@
#----------------------------------------------------------------------------# #----------------------------------------------------------------------------#
############################################################################## ##############################################################################
source(paste0(getwd(),"/functions/resali.R")) source("/home/corentin/Documents/These/Recherche/Simulations/RProject/Scripts/Analysis/functions/resali.R")
generate_resali <- function(scenario=NULL,grp=NULL) { generate_resali <- function(scenario=NULL,grp=NULL) {
scen <- as.numeric(gsub("[A,B,C,D,E,F,G,_]","",substr(scenario,0,3))) scen <- as.numeric(gsub("[A,B,C,D,E,F,G,_]","",substr(scenario,0,3)))
@ -113,15 +113,18 @@ generate_resali <- function(scenario=NULL,grp=NULL) {
return(df_res) return(df_res)
} }
#results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
#results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
#results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x)))
#results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x)))
results <- c(sapply(c(2:4),function(x) paste0(x,c('A','B','C'))),sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G')))) results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G')))) results <- c(sapply(c(50,100,300),function(x) paste0(results,'_',x)))
results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x))) results2 <- c(sapply(c(50,100,300),function(x) paste0(results2,'_',x)))
results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x)))
results <- sort(results) results <- sort(results)
@ -144,13 +147,27 @@ for (r in results) {
## Liste des scenarios ## Liste des scenarios
results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G')))) #results <- c(sapply(1:4,function(x) paste0(x,c('A','B','C','D','E'))),sapply(5:9,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G')))) #results2 <- c(sapply(10:20,function(x) paste0(x,c('A','B','C','D','E','F','G'))))
results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x))) #results <- c(sapply(c(50,100,200,300),function(x) paste0(results,'_',x)))
results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x))) #results2 <- c(sapply(c(50,100,200,300),function(x) paste0(results2,'_',x)))
#results <- sort(results)
#results2 <- sort(results2)
#results <- c(results,results2)
results <- c(sapply(c(2:4),function(x) paste0(x,c('A','B','C'))),sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(c(50,100,300),function(x) paste0(results,'_',x)))
results2 <- c(sapply(c(50,100,300),function(x) paste0(results2,'_',x)))
results <- sort(results) results <- sort(results)

View File

@ -0,0 +1,279 @@
##############################################################################
#----------------------------------------------------------------------------#
################################### RESIDIF ##################################
#----------------------------------------------------------------------------#
##############################################################################
generate_residif <- function(scenario=NULL,grp=NULL) {
scen <- as.numeric(gsub("[A,B,C,D,E,F,G,_]","",substr(scenario,0,3)))
if (substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50") {
N <- 50
}
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="100") {
N <- 100
}
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="200") {
N <- 200
}
if (substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario))=="300") {
N <- 300
}
if (scen<5) {
dat <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Data/NoDIF/N',N,'/scenario_',scenario,'.csv'))
}
if (scen>=5) {
dat <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N',N,'/scenario_',scenario,'.csv'))
}
if (scen%in%c(3,4,13:20)) {
res <- residif(df=dat[dat$replication==1,],items = paste0("item",1:7),grp="TT",verbose=FALSE)
df_res <- data.frame(dif.detect.1=ifelse(length(res$dif.items)>=1,res$dif.items[1],NA),
dif.detect.2=ifelse(length(res$dif.items)>=2,res$dif.items[2],NA),
dif.detect.3=ifelse(length(res$dif.items)>=3,res$dif.items[3],NA),
dif.detect.4=ifelse(length(res$dif.items)>=4,res$dif.items[4],NA),
dif.detect.5=ifelse(length(res$dif.items)>=5,res$dif.items[5],NA),
dif.detect.6=ifelse(length(res$dif.items)>=6,res$dif.items[6],NA),
dif.detect.7=ifelse(length(res$dif.items)>=7,res$dif.items[7],NA),
dif.detect.unif.1=ifelse(length(res$uniform)>=1,res$uniform[1],NA),
dif.detect.unif.2=ifelse(length(res$uniform)>=2,res$uniform[2],NA),
dif.detect.unif.3=ifelse(length(res$uniform)>=3,res$uniform[3],NA),
dif.detect.unif.4=ifelse(length(res$uniform)>=4,res$uniform[4],NA),
dif.detect.unif.5=ifelse(length(res$uniform)>=5,res$uniform[5],NA),
dif.detect.unif.6=ifelse(length(res$uniform)>=6,res$uniform[6],NA),
dif.detect.unif.7=ifelse(length(res$uniform)>=7,res$uniform[7],NA),
N=N,
nbdif=ifelse(scen<=4,0,ifelse(scen<=16,2,3)),
true.dif.1=ifelse(scen<=4,NA,unique(dat[dat$replication==1,]$dif1)),
true.dif.2=ifelse(scen<=4,NA,unique(dat[dat$replication==1,]$dif2)),
true.dif.3=ifelse(scen<=16,NA,unique(dat[dat$replication==1,]$dif3))
)
for (k in 2:1000) {
if (k%%100==0) {
cat(paste0('N=',k,'/1000\n'))
}
res <- residif(df=dat[dat$replication==k,],items = paste0("item",1:7),grp="TT",verbose=FALSE)
df_res2 <- data.frame(dif.detect.1=ifelse(length(res$dif.items)>=1,res$dif.items[1],NA),
dif.detect.2=ifelse(length(res$dif.items)>=2,res$dif.items[2],NA),
dif.detect.3=ifelse(length(res$dif.items)>=3,res$dif.items[3],NA),
dif.detect.4=ifelse(length(res$dif.items)>=4,res$dif.items[4],NA),
dif.detect.5=ifelse(length(res$dif.items)>=5,res$dif.items[5],NA),
dif.detect.6=ifelse(length(res$dif.items)>=6,res$dif.items[6],NA),
dif.detect.7=ifelse(length(res$dif.items)>=7,res$dif.items[7],NA),
dif.detect.unif.1=ifelse(length(res$uniform)>=1,res$uniform[1],NA),
dif.detect.unif.2=ifelse(length(res$uniform)>=2,res$uniform[2],NA),
dif.detect.unif.3=ifelse(length(res$uniform)>=3,res$uniform[3],NA),
dif.detect.unif.4=ifelse(length(res$uniform)>=4,res$uniform[4],NA),
dif.detect.unif.5=ifelse(length(res$uniform)>=5,res$uniform[5],NA),
dif.detect.unif.6=ifelse(length(res$uniform)>=6,res$uniform[6],NA),
dif.detect.unif.7=ifelse(length(res$uniform)>=7,res$uniform[7],NA),
N=N,
nbdif=ifelse(scen<=4,0,ifelse(scen<=16,2,3)),
true.dif.1=ifelse(scen<=4,NA,unique(dat[dat$replication==k,]$dif1)),
true.dif.2=ifelse(scen<=4,NA,unique(dat[dat$replication==k,]$dif2)),
true.dif.3=ifelse(scen<=16,NA,unique(dat[dat$replication==k,]$dif3)))
df_res <- rbind(df_res,df_res2)
}
}
else if (scen%in%c(1,2,5:12)) {
res <- residif(df=dat[dat$replication==1,],items = paste0("item",1:4),grp="TT",verbose=FALSE)
df_res <- data.frame(dif.detect.1=ifelse(length(res$dif.items)>=1,res$dif.items[1],NA),
dif.detect.2=ifelse(length(res$dif.items)>=2,res$dif.items[2],NA),
dif.detect.3=ifelse(length(res$dif.items)>=3,res$dif.items[3],NA),
dif.detect.4=ifelse(length(res$dif.items)>=4,res$dif.items[4],NA),
dif.detect.unif.1=ifelse(length(res$uniform)>=1,res$uniform[1],NA),
dif.detect.unif.2=ifelse(length(res$uniform)>=2,res$uniform[2],NA),
dif.detect.unif.3=ifelse(length(res$uniform)>=3,res$uniform[3],NA),
dif.detect.unif.4=ifelse(length(res$uniform)>=4,res$uniform[4],NA),
N=N,
nbdif=ifelse(scen<=4,0,ifelse(scen<=8,1,2)),
true.dif.1=ifelse(scen<=4,NA,unique(dat[dat$replication==1,]$dif1)),
true.dif.2=ifelse(scen<=8,NA,unique(dat[dat$replication==1,]$dif2))
)
for (k in 2:1000) {
if (k%%100==0) {
cat(paste0('N=',k,'/1000\n'))
}
res <- residif(df=dat[dat$replication==k,],items = paste0("item",1:4),grp="TT",verbose=FALSE)
df_res2 <- data.frame(dif.detect.1=ifelse(length(res$dif.items)>=1,res$dif.items[1],NA),
dif.detect.2=ifelse(length(res$dif.items)>=2,res$dif.items[2],NA),
dif.detect.3=ifelse(length(res$dif.items)>=3,res$dif.items[3],NA),
dif.detect.4=ifelse(length(res$dif.items)>=4,res$dif.items[4],NA),
dif.detect.unif.1=ifelse(length(res$uniform)>=1,res$uniform[1],NA),
dif.detect.unif.2=ifelse(length(res$uniform)>=2,res$uniform[2],NA),
dif.detect.unif.3=ifelse(length(res$uniform)>=3,res$uniform[3],NA),
dif.detect.unif.4=ifelse(length(res$uniform)>=4,res$uniform[4],NA),
N=N,
nbdif=ifelse(scen<=4,0,ifelse(scen<=8,1,2)),
true.dif.1=ifelse(scen<=4,NA,unique(dat[dat$replication==k,]$dif1)),
true.dif.2=ifelse(scen<=8,NA,unique(dat[dat$replication==k,]$dif2)))
df_res <- rbind(df_res,df_res2)
}
}
return(df_res)
}
results <- c(sapply(c(2,4),function(x) paste0(x,c('A','B','C'))),sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(c(50,100,300),function(x) paste0(results,'_',x)))
results2 <- c(sapply(c(50,100,300),function(x) paste0(results2,'_',x)))
results <- sort(results)
results2 <- sort(results2)
results <- c(results,results2)
for (r in c(results[73:138])) {
cat(paste0(r,"\n"))
cat(paste0("-------------------------------------------","\n"))
write.csv(generate_residif(r,"TT"),paste0("/home/corentin/Documents/These/Recherche/residif/detection/",r,".csv"))
cat(paste0("-------------------------------------------","\n"))
}
##############################################################################
#----------------------------------------------------------------------------#
################################### NEWDATA ##################################
#----------------------------------------------------------------------------#
##############################################################################
## Liste des scenarios
results <- c(sapply(c(2,4),function(x) paste0(x,c('A','B','C'))),sapply(c(6,8),function(x) paste0(x,c('A','B','C','D','E'))))
results2 <- c(sapply(seq(10,20,2),function(x) paste0(x,c('A','B','C','D','E'))))
results <- c(sapply(c(50,100,300),function(x) paste0(results,'_',x)))
results2 <- c(sapply(c(50,100,300),function(x) paste0(results2,'_',x)))
results <- sort(results)
results2 <- sort(results2)
results <- c(results,results2)
## Importer l'analyse resali pour chaque scenario
for (r in results) {
cat('--------------------------------------------------------------------------\n')
cat(paste0(r,"\n"))
cat('--------------------------------------------------------------------------\n')
#### Importer les datas
scen <- as.numeric(gsub("[A,B,C,D,E,F,G,_]","",substr(r,0,3)))
if (substr(r,start=nchar(r)-1,stop=nchar(r))=="50") {
N <- 50
}
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="100") {
N <- 100
}
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="200") {
N <- 200
}
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="300") {
N <- 300
}
if (scen<5) {
datt <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Data/NoDIF/N',N,'/scenario_',r,'.csv'))
}
if (scen>=5) {
datt <- read.csv(paste0('/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N',N,'/scenario_',r,'.csv'))
}
#### Importer l'analyse
analyse <- read.csv(paste0('/home/corentin/Documents/These/Recherche/residif/detection/',r,".csv"))
#### Pour chaque replication
for (k in 1:1000) {
if (k%%100==0) {
cat(paste0("N = ",k," / 1000\n"))
}
datt[datt$replication==k,"dif.detect.1"] <- analyse[analyse$X==k,"dif.detect.1"]
datt[datt$replication==k,"dif.detect.2"] <- analyse[analyse$X==k,"dif.detect.2"]
datt[datt$replication==k,"dif.detect.3"] <- analyse[analyse$X==k,"dif.detect.3"]
datt[datt$replication==k,"dif.detect.4"] <- analyse[analyse$X==k,"dif.detect.4"]
datt[datt$replication==k,"dif.detect.unif.1"] <- analyse[analyse$X==k,"dif.detect.unif.1"]
datt[datt$replication==k,"dif.detect.unif.2"] <- analyse[analyse$X==k,"dif.detect.unif.2"]
datt[datt$replication==k,"dif.detect.unif.3"] <- analyse[analyse$X==k,"dif.detect.unif.3"]
datt[datt$replication==k,"dif.detect.unif.4"] <- analyse[analyse$X==k,"dif.detect.unif.4"]
if (scen==3 | scen==4 | scen>=13) {
datt[datt$replication==k,"dif.detect.5"] <- analyse[analyse$X==k,"dif.detect.5"]
datt[datt$replication==k,"dif.detect.6"] <- analyse[analyse$X==k,"dif.detect.6"]
datt[datt$replication==k,"dif.detect.7"] <- analyse[analyse$X==k,"dif.detect.7"]
datt[datt$replication==k,"dif.detect.unif.5"] <- analyse[analyse$X==k,"dif.detect.unif.5"]
datt[datt$replication==k,"dif.detect.unif.6"] <- analyse[analyse$X==k,"dif.detect.unif.6"]
datt[datt$replication==k,"dif.detect.unif.7"] <- analyse[analyse$X==k,"dif.detect.unif.7"]
}
}
datt[is.na(datt$dif.detect.1),"dif.detect.1"] <- ""
datt[is.na(datt$dif.detect.2),"dif.detect.2"] <- ""
datt[is.na(datt$dif.detect.3),"dif.detect.3"] <- ""
datt[is.na(datt$dif.detect.4),"dif.detect.4"] <- ""
datt[is.na(datt$dif.detect.unif.1),"dif.detect.unif.1"] <- ""
datt[is.na(datt$dif.detect.unif.2),"dif.detect.unif.2"] <- ""
datt[is.na(datt$dif.detect.unif.3),"dif.detect.unif.3"] <- ""
datt[is.na(datt$dif.detect.unif.4),"dif.detect.unif.4"] <- ""
if (scen==3 | scen==4 | scen>=13) {
datt[is.na(datt$dif.detect.5),"dif.detect.5"] <- ""
datt[is.na(datt$dif.detect.6),"dif.detect.6"] <- ""
datt[is.na(datt$dif.detect.7),"dif.detect.7"] <- ""
datt[is.na(datt$dif.detect.unif.5),"dif.detect.unif.5"] <- ""
datt[is.na(datt$dif.detect.unif.6),"dif.detect.unif.6"] <- ""
datt[is.na(datt$dif.detect.unif.7),"dif.detect.unif.7"] <- ""
}
write.csv(datt,paste0("/home/corentin/Documents/These/Recherche/residif/detection_data/",r,".csv"))
}
for (r in results) {
cat('--------------------------------------------------------------------------\n')
cat(paste0(r,"\n"))
cat('--------------------------------------------------------------------------\n')
#### Importer les datas
scen <- as.numeric(gsub("[A,B,C,D,E,F,G,_]","",substr(r,0,3)))
if (substr(r,start=nchar(r)-1,stop=nchar(r))=="50") {
N <- 50
}
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="100") {
N <- 100
}
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="200") {
N <- 200
}
if (substr(r,start=nchar(r)-2,stop=nchar(r))=="300") {
N <- 300
}
#### Importer l'analyse
analyse <- read.csv(paste0("/home/corentin/Documents/These/Recherche/residif/detection_data/",r,".csv"))
analyse[is.na(analyse)] <- ""
names(analyse)[names(analyse)=="dif.detect.1"] <- "dif_detect_1"
names(analyse)[names(analyse)=="dif.detect.2"] <- "dif_detect_2"
names(analyse)[names(analyse)=="dif.detect.3"] <- "dif_detect_3"
names(analyse)[names(analyse)=="dif.detect.4"] <- "dif_detect_4"
names(analyse)[names(analyse)=="dif.detect.unif.1"] <- "dif_detect_unif_1"
names(analyse)[names(analyse)=="dif.detect.unif.2"] <- "dif_detect_unif_2"
names(analyse)[names(analyse)=="dif.detect.unif.3"] <- "dif_detect_unif_3"
names(analyse)[names(analyse)=="dif.detect.unif.4"] <- "dif_detect_unif_4"
if (scen==3 | scen==4 | scen>=13) {
names(analyse)[names(analyse)=="dif.detect.5"] <- "dif_detect_5"
names(analyse)[names(analyse)=="dif.detect.6"] <- "dif_detect_6"
names(analyse)[names(analyse)=="dif.detect.7"] <- "dif_detect_7"
names(analyse)[names(analyse)=="dif.detect.unif.5"] <- "dif_detect_unif_5"
names(analyse)[names(analyse)=="dif.detect.unif.6"] <- "dif_detect_unif_6"
names(analyse)[names(analyse)=="dif.detect.unif.7"] <- "dif_detect_unif_7"
}
analyse <- analyse[,!names(analyse) %in% c("X","X.1","X.2")]
write.csv(analyse,paste0("/home/corentin/Documents/These/Recherche/residif/detection_data/",r,".csv"))
}

View File

@ -15,7 +15,7 @@ generate_diff_irt <- function(J=7,M=4) {
} }
difficulties = matrix(c(0), J,M-1) difficulties = matrix(c(0), J,M-1)
rownames(difficulties)=paste("item",1:J) rownames(difficulties)=paste("item",1:J)
colnames(difficulties)=paste("Moda", 1:(M-1)) colnames(difficulties)=paste("delta", 1:(M-1))
for (j in 1:J){ for (j in 1:J){
difficulties[j,1] = qnorm(j/(J+1)) difficulties[j,1] = qnorm(j/(J+1))
} }

View File

@ -0,0 +1,375 @@
*=================================================================================================================================================
* Date : 2024-01-23
* Stata version : Stata 18 SE
*
* This program analyses simulated data accounting for DIF through a partial credit model
*
* ado-files needed : - pcm, rosali (version 5.5 October 25, 2023, available on gitea)
*
*
*================================================================================================================================================
adopath+"/home/corentin/Documents/These/Recherche/ROSALI-SIM/Modules/rosali_custom"
local N = "50 100 300"
local ss = "18 20"
foreach s in `ss' {
foreach Nnn in `N' {
local Nn = `Nnn'
local path_data = "/home/corentin/Documents/These/Recherche/Simulations/Analysis/RESALI/Detection_data"
local path_res = "/home/corentin/Documents/These/Recherche/Simulations/Analysis/RESALI/Results/N`Nn'"
local scenarios = "A B C D E"
if (`s' <= 4) {
local scenarios = "A B C"
}
foreach scen in `scenarios' {
clear
import delim "`path_data'/`s'`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear
rename TT tt
if (`s'<=2) {
local nbitems=4
}
else if (`s'<=4) {
local nbitems=7
}
else if (`s'<=12) {
local nbitems=4
}
else {
local nbitems=7
}
if (mod(`s',2)==0) {
local nbmoda=3
}
else {
local nbmoda=1
}
if (`s'<=4) {
local nbdif=0
}
else if (`s'<=8) {
local nbdif=1
}
else if (`s'<=16) {
local nbdif=2
}
else {
local nbdif=3
}
* taillemat = Maximum J*M cases pour les items par et J*M cases pour les dif par + J cases pour les DIF detect + nbdif cases pour dif réel
local taillemat=2*`nbitems'*`nbmoda'+`nbitems'+`nbdif'+2
if (mod(`s',2)==0) {
local taillemat=2*`nbitems'*`nbmoda'+`nbitems'+`nbitems'+`nbdif'+2
}
local colna=""
forvalues i=1/`nbitems' {
forvalues z=1/`nbmoda' {
local colna = "`colna'"+"item`i'_`z' "
local colna = "`colna'"+"dif_`i'_`z' "
}
}
forvalues i=1/`nbitems' {
if (mod(`s',2)==1) {
local colna = "`colna'"+"dif_detect_`i' "
}
if (mod(`s',2)==0) {
local colna = "`colna'"+"dif_detect_`i' "+"dif_detect_unif_`i' "
}
}
forvalues i=1/`nbdif' {
local colna = "`colna'"+"real_dif_`i' "
}
local colna = "`colna'" + "beta " + "se_beta"
mat outmat = J(1000,`taillemat',.)
mat colnames outmat= `colna'
di "Scenario `s'`scen' / N=`Nnn'"
forvalues k=1/1000 {
if (mod(`k',100)==0) {
di "`k'/1000"
}
preserve
qui keep if replication==`k'
* MERGE des modalités si non représentées
if (`nbmoda'>1 & `Nn'==50) {
local com_z = 0
qui gen comz = 0
forvalues j = 1 / `nbitems' {
local recoda_`j' = 0
qui tab item`j' if tt == 0, matrow(rect1_g0_`j') matcell(nbrt1_g0_`j')
local maxm`j'_t1_g0 = rect1_g0_`j'[r(r),1]
local minm`j'_t1_g0 = rect1_g0_`j'[1,1]
qui tab item`j' if tt == 1, matrow(rect1_g1_`j') matcell(nbrt1_g1_`j')
local minm`j'_t1_g1 = rect1_g1_`j'[1,1]
local maxm`j'_t1_g1 = rect1_g1_`j'[r(r),1]
local minm_`j' = min(`minm`j'_t1_g0',`minm`j'_t1_g1')
local maxm_`j' = max(`maxm`j'_t1_g0',`maxm`j'_t1_g1')
local nbm_`j' = `=`maxm_`j''-`minm_`j'''
if `minm_`j'' != 0 & `com_z' == 0 {
local com_z = 1
}
qui count if item`j' == 3 & tt == 0
local mod3plac = r(N)
qui count if item`j' == 3 & tt == 1
local mod3tt = r(N)
local nb_rn3 = min(`mod3plac',`mod3tt')
if `nb_rn3'==0 {
qui replace comz = 1
}
forvalues m = 0/`=`nbm_`j''-1' {
qui count if item`j' == `m' & tt == 0
local nb_rn1_g0 = r(N)
qui count if item`j' == `m' & tt == 1
local nb_rn1_g1 = r(N)
local nb_rn = min(`nb_rn1_g0',`nb_rn1_g1')
if `nb_rn' == 0 {
qui replace comz = 1
local recoda_`j' = 1
if `m' == 0 | `m' < `minm`j'_t1_g0' | `m' < `minm`j'_t1_g1' {
local stop = 1
forvalues kk = 1/`=`nbm_`j''-`m'' {
qui count if item`j' == `=`m' + `kk'' & tt == 0
local v`kk'1_0 = r(N)
qui count if item`j' == `=`m' + `kk'' & tt == 1
local v`kk'1_1 = r(N)
if (`v`kk'1_0' != 0 | `v`kk'1_1' != 0) & `stop' != 0 {
qui replace item`j'= `=`m'+`kk'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'=`=`m'+`kk'' if item``=`j'+`nbitems'''==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
}
}
else if `m' == `=`nbm_`j''-1' | `m' >= `maxm`j'_t1_g1' {
local stop = 1
forvalues kk = 1/`=`m'' {
qui count if item`j' == `=`m' - `kk'' & tt == 0
local v`kk'1_0 = r(N)
qui count if item`j' == `=`m' - `kk'' & tt == 1
local v`kk'1_1 = r(N)
if (`v`kk'1_0' != 0 | `v`kk'1_1' != 0) & `stop' != 0 {
qui replace item`j'= `=`m' - `kk'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'= `=`m' - `kk'' if item`zzz'==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
}
}
else {
if runiform()>0.5{
local stop = 1
forvalues kk = 1/`m' {
qui count if item`j' == `=`m' - `kk'' & tt == 0
local v`kk'1_0 = r(N)
qui count if item`j' == `=`m' - `kk'' & tt == 1
local v`kk'1_1 = r(N)
if (`v`kk'1_0' != 0 | `v`kk'1_1' != 0) & `stop' != 0 {
qui replace item`j'= `=`m'-`kk'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'=`=`m'-`kk'' if item``=`j'+`nbitems'''==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
}
}
else {
local stop = 1
forvalues kk = 1/`=`nbm_`j''-`m'' {
qui count if item`j' == `=`m' + `kk'' & tt == 0
local v`kk'1_0 = r(N)
qui count if item`j' == `=`m' + `kk'' & tt == 1
local v`kk'1_1 = r(N)
if (`v`kk'1_0' != 0 | `v`kk'1_1' != 0) & `stop' != 0{
qui replace item`j'=`=`m' + `kk'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'=`=`m' + `kk'' if item``=`j'+`nbitems'''==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
else {
if `stop' != 0 {
qui replace item`j'= `nbm_`j'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'= `nbm_`j'' if item``=`j'+`nbitems'''==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
}
}
}
}
}
}
qui levelsof item`j'
local val = r(levels)
local checker: word 1 of `val'
local checker2: word 2 of `val'
local checker3: word 3 of `val'
local nummoda=r(r)
local nbmoda_`j'=`nummoda'-1
if (`nummoda'==2) {
qui recode item`j' (`checker'=0) (`checker2'=1)
}
if (`nummoda'==3) {
if (`checker'!=0) {
qui recode item`j' (`checker'=0) (`checker2'=1) (`checker3'=2)
}
else if (`checker2'!=1) {
qui recode item`j' (`checker2'=1) (`checker3'=2)
}
else if (`checker3'!=2) {
qui recode item`j' (`checker3'=2)
}
}
}
qui valuesof comz
local val = r(values)
local checker: word 1 of `val'
}
else {
forvalues jj=1/`nbitems' {
local nbmoda_`jj'=`nbmoda'
}
}
local nbitems2 = 2*`nbitems'
* Calculer le nbre d'items détectés
local nbdetect = 0
local stop = 0
forvalues jj=1/`nbitems' {
qui levelsof dif_detect_`jj'
local detected=r(levels)
if (`stop'==0) {
mat testm=J(1,1,.)
if (`detected'==testm[1,1]) {
local stop = 1
local nbdetect = `jj'-1
}
}
}
* Stocker les items détectés +
* Définition des contraintes
local csrt=0
mat testm=J(1,1,0)
forvalues u=1/`nbdetect' {
qui levelsof dif_detect_`u'
local detected=r(levels)
local difitems`u'=`detected'
local i=`difitems`u''
qui levelsof dif_detect_unif_`u'
local detected_unif=r(levels)
if (`nbmoda_`i''==3 & `detected_unif'!=testm[1,1]){
local constrnt`u' = "constraint `u' 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
qui `constrnt`u''
local v=`u'+100
local constrnt`u'_2 = "constraint `v' 3*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([3.item`i']_cons-([3.item`i']_cons+[3.item`i'] tt))"
qui `constrnt`u'_2'
}
if (`nbmoda_`i''==2 & `detected_unif'!=testm[1,1]){
local constrnt`u' = "constraint `u' 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
qui `constrnt`u''
}
}
* Définition du modèle
local mod "gsem "
local conformula = ""
forvalues i=1/`nbitems' {
local mod = "`mod'"+"(1.item`i'<-THETA@1)"
if (`nbmoda_`i''==3) {
local mod = "`mod'"+"(2.item`i'<-THETA@2)(3.item`i'<-THETA@3)"
}
else if (`nbmoda_`i''==2) {
local mod = "`mod'"+"(2.item`i'<-THETA@2)"
}
}
forvalues u=1/`nbdetect' {
local v=`difitems`u''
local mod = "`mod'"+"(1.item`v'<-THETA@1 tt)"
if (`nbmoda_`v''==3) {
local mod = "`mod'"+"(2.item`v'<-THETA@2 tt)(3.item`v'<-THETA@3 tt)"
}
else if (`nbmoda_`v''==2) {
local mod = "`mod'"+"(2.item`v'<-THETA@2 tt)"
}
local w= 100+`u'
qui levelsof dif_detect_unif_`u'
local detected=r(levels)
local unif_`u'=r(levels)
if (`detected'!=testm[1,1] & `nbmoda_`v''==3) {
local conformula = "`conformula'" + "`u' " + "`w' "
}
else if (`detected'!=testm[1,1] & `nbmoda_`v''==2) {
local conformula = "`conformula'" + "`u' "
}
}
if ("`conformula'" != "") {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(`conformula')"
}
else {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent"
}
*calcul du modèle
qui `mod'
mat V=r(table)
mat W=V[1..2,1...]
* compilation
forvalues j=1/`nbitems' {
forvalues z=1/`nbmoda_`j'' {
mat outmat[`k',colnumb(outmat,"item`j'_`z'")] = W[1,colnumb(W,"`z'.item`j':_cons")]
}
}
* compilation DIF
forvalues u=1/`nbdetect' {
local j=`difitems`u''
forvalues z=1/`nbmoda_`j'' {
mat outmat[`k',colnumb(outmat,"dif_`u'_`z'")] = W[1,colnumb(W,"`z'.item`j':tt")]
}
mat outmat[`k',colnumb(outmat,"dif_detect_`u'")] = `j'
if (mod(`s',2)==0) {
mat outmat[`k',colnumb(outmat,"dif_detect_unif_`u'")] = `unif_`u''
}
}
* Stocker les items de DIF originaux
if (`nbdif' > 0) {
qui levelsof dif1
local ldif1 = r(levels)
local diff1: word 1 of `ldif1'
qui mat outmat[`k',colnumb(outmat,"real_dif_1")]=`diff1'
if (`nbdif' > 1) {
qui levelsof dif2
local ldif2 = r(levels)
local diff2: word 1 of `ldif2'
qui mat outmat[`k',colnumb(outmat,"real_dif_2")]=`diff2'
if (`nbdif' > 2) {
qui levelsof dif3
local ldif3 = r(levels)
local diff3: word 1 of `ldif3'
qui mat outmat[`k',colnumb(outmat,"real_dif_3")]=`diff3'
}
}
}
qui mat outmat[`k',colnumb(outmat,"beta")]=W[1,colnumb(W,"THETA:tt")]
qui mat outmat[`k',colnumb(outmat,"se_beta")]=W[2,colnumb(W,"THETA:tt")]
restore
}
putexcel set "`path_res'/`s'`scen'_`Nn'_original.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
}

View File

@ -0,0 +1,388 @@
*=================================================================================================================================================
* Date : 2024-01-23
* Stata version : Stata 18 SE
*
* This program analyses simulated data accounting for DIF through a partial credit model
*
* ado-files needed : - pcm, rosali (version 5.5 October 25, 2023, available on gitea)
*
*
*================================================================================================================================================
adopath+"/home/corentin/Documents/These/Recherche/Simulations/Modules/rosali_custom"
local N = "50 100 200 300"
local ss = "2 4 8 12 16 20"
foreach s in `ss' {
foreach Nnn in `N' {
local Nn = `Nnn'
local path_data = "/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N`Nn'"
if (`s'<=4) {
local path_data = "/home/corentin/Documents/These/Recherche/Simulations/Data/NoDIF/N`Nn'"
}
local path_res = "/home/corentin/Documents/These/Recherche/Simulations/Analysis/ROSALI-DIF-IMPROVED/MIMIC-NOLRT/N`Nn'"
local path_log = "/home/corentin/Documents/These/Recherche/Simulations/Analysis/ROSALI-DIF/log/"
local scenarios = "A B C D E"
if (`s' <= 4) {
local scenarios = "A B C"
}
foreach scen in `scenarios' {
clear
import delim "`path_data'/scenario_`s'`scen'_`Nn'.csv", encoding(ISO-8859-2) case(preserve) clear
rename TT tt
log using "`path_log'/log_`s'`scen'_`Nn'.log", replace
if (`s'<=2) {
local nbitems=4
}
else if (`s'<=4) {
local nbitems=7
}
else if (`s'<=12) {
local nbitems=4
}
else {
local nbitems=7
}
if (mod(`s',2)==0) {
local nbmoda=3
}
else {
local nbmoda=1
}
if (`s'<=4) {
local nbdif=0
}
else if (`s'<=8) {
local nbdif=1
}
else if (`s'<=16) {
local nbdif=2
}
else {
local nbdif=3
}
* taillemat = Maximum J*M cases pour les items par et J*M cases pour les dif par + J cases pour les DIF detect + nbdif cases pour dif réel
local taillemat=2*`nbitems'*`nbmoda'+`nbitems'+`nbdif'+2+1
if (mod(`s',2)==0) {
local taillemat=2*`nbitems'*`nbmoda'+`nbitems'+`nbitems'+`nbdif'+2+1
}
local colna=""
forvalues i=1/`nbitems' {
forvalues z=1/`nbmoda' {
local colna = "`colna'"+"item`i'_`z' "
local colna = "`colna'"+"dif_`i'_`z' "
}
}
forvalues i=1/`nbitems' {
if (mod(`s',2)==1) {
local colna = "`colna'"+"dif_detect_`i' "
}
if (mod(`s',2)==0) {
local colna = "`colna'"+"dif_detect_`i' "+"dif_detect_unif_`i' "
}
}
forvalues i=1/`nbdif' {
local colna = "`colna'"+"real_dif_`i' "
}
local colna = "`colna'" + "beta " + "se_beta " + "lrt_passed"
mat outmat = J(1000,`taillemat',.)
mat colnames outmat= `colna'
di "Scenario `s'`scen' / N=`Nnn'"
forvalues k=1/1000 {
di "###################################################################################"
di "###################################################################################"
di "###################################################################################"
di "Scenario `s'`scen' N=`Nn' ########## `k'/1000"
di "###################################################################################"
di "###################################################################################"
di "###################################################################################"
preserve
qui keep if replication==`k'
* MERGE des modalités si non représentées
if (`nbmoda'>1 & `Nn'==50) {
local com_z = 0
qui gen comz = 0
forvalues j = 1 / `nbitems' {
local recoda_`j' = 0
qui tab item`j' if tt == 0, matrow(rect1_g0_`j') matcell(nbrt1_g0_`j')
local maxm`j'_t1_g0 = rect1_g0_`j'[r(r),1]
local minm`j'_t1_g0 = rect1_g0_`j'[1,1]
qui tab item`j' if tt == 1, matrow(rect1_g1_`j') matcell(nbrt1_g1_`j')
local minm`j'_t1_g1 = rect1_g1_`j'[1,1]
local maxm`j'_t1_g1 = rect1_g1_`j'[r(r),1]
local minm_`j' = min(`minm`j'_t1_g0',`minm`j'_t1_g1')
local maxm_`j' = max(`maxm`j'_t1_g0',`maxm`j'_t1_g1')
local nbm_`j' = `=`maxm_`j''-`minm_`j'''
if `minm_`j'' != 0 & `com_z' == 0 {
local com_z = 1
}
qui count if item`j' == 3 & tt == 0
local mod3plac = r(N)
qui count if item`j' == 3 & tt == 1
local mod3tt = r(N)
local nb_rn3 = min(`mod3plac',`mod3tt')
if `nb_rn3'==0 {
qui replace comz = 1
}
forvalues m = 0/`=`nbm_`j''-1' {
qui count if item`j' == `m' & tt == 0
local nb_rn1_g0 = r(N)
qui count if item`j' == `m' & tt == 1
local nb_rn1_g1 = r(N)
local nb_rn = min(`nb_rn1_g0',`nb_rn1_g1')
if `nb_rn' == 0 {
qui replace comz = 1
local recoda_`j' = 1
if `m' == 0 | `m' < `minm`j'_t1_g0' | `m' < `minm`j'_t1_g1' {
local stop = 1
forvalues kk = 1/`=`nbm_`j''-`m'' {
qui count if item`j' == `=`m' + `kk'' & tt == 0
local v`kk'1_0 = r(N)
qui count if item`j' == `=`m' + `kk'' & tt == 1
local v`kk'1_1 = r(N)
if (`v`kk'1_0' != 0 | `v`kk'1_1' != 0) & `stop' != 0 {
qui replace item`j'= `=`m'+`kk'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'=`=`m'+`kk'' if item``=`j'+`nbitems'''==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
}
}
else if `m' == `=`nbm_`j''-1' | `m' >= `maxm`j'_t1_g1' {
local stop = 1
forvalues kk = 1/`=`m'' {
qui count if item`j' == `=`m' - `kk'' & tt == 0
local v`kk'1_0 = r(N)
qui count if item`j' == `=`m' - `kk'' & tt == 1
local v`kk'1_1 = r(N)
if (`v`kk'1_0' != 0 | `v`kk'1_1' != 0) & `stop' != 0 {
qui replace item`j'= `=`m' - `kk'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'= `=`m' - `kk'' if item`zzz'==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
}
}
else {
if runiform()>0.5{
local stop = 1
forvalues kk = 1/`m' {
qui count if item`j' == `=`m' - `kk'' & tt == 0
local v`kk'1_0 = r(N)
qui count if item`j' == `=`m' - `kk'' & tt == 1
local v`kk'1_1 = r(N)
if (`v`kk'1_0' != 0 | `v`kk'1_1' != 0) & `stop' != 0 {
qui replace item`j'= `=`m'-`kk'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'=`=`m'-`kk'' if item``=`j'+`nbitems'''==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
}
}
else {
local stop = 1
forvalues kk = 1/`=`nbm_`j''-`m'' {
qui count if item`j' == `=`m' + `kk'' & tt == 0
local v`kk'1_0 = r(N)
qui count if item`j' == `=`m' + `kk'' & tt == 1
local v`kk'1_1 = r(N)
if (`v`kk'1_0' != 0 | `v`kk'1_1' != 0) & `stop' != 0{
qui replace item`j'=`=`m' + `kk'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'=`=`m' + `kk'' if item``=`j'+`nbitems'''==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
else {
if `stop' != 0 {
qui replace item`j'= `nbm_`j'' if item`j'==`m'
local zzz=`j'+`nbitems'
*qui replace item`zzz'= `nbm_`j'' if item``=`j'+`nbitems'''==`m'
*di "WARNING SCENARIO `k': items `j': answers `m' and `=`m'+`kk'' merged"
local stop = 0
}
}
}
}
}
}
}
qui levelsof item`j'
local val = r(levels)
local checker: word 1 of `val'
local checker2: word 2 of `val'
local checker3: word 3 of `val'
local nummoda=r(r)
local nbmoda_`j'=`nummoda'-1
if (`nummoda'==2) {
qui recode item`j' (`checker'=0) (`checker2'=1)
}
if (`nummoda'==3) {
if (`checker'!=0) {
qui recode item`j' (`checker'=0) (`checker2'=1) (`checker3'=2)
}
else if (`checker2'!=1) {
qui recode item`j' (`checker2'=1) (`checker3'=2)
}
else if (`checker3'!=2) {
qui recode item`j' (`checker3'=2)
}
}
}
qui valuesof comz
local val = r(values)
local checker: word 1 of `val'
}
else {
forvalues jj=1/`nbitems' {
local nbmoda_`jj'=`nbmoda'
}
}
* ROSALI
rosali_nolrt_screening item1-item`nbitems' item1-item`nbitems', group(tt)
qui mat resmat=r(difitems)
local nbitems2 = 2*`nbitems'
mat lrt_passed = resmat[1,`nbitems2'+1]
* Calculer le nbre d'items détectés
local nbdetect = 0
local stop = 0
forvalues jj=1/`nbitems' {
if (`stop'==0) {
mat testm=J(1,1,.)
if (resmat[1,`jj']==testm[1,1]) {
local stop = 1
local nbdetect = `jj'-1
}
}
}
* Stocker les items détectés +
* Définition des contraintes
local csrt=0
mat testm=J(1,1,0)
forvalues u=1/`nbdetect' {
local difitems`u'=resmat[1,`u']
local i=`difitems`u''
if (`nbmoda_`i''==3 & resmat[1,`nbitems'+`i']!=testm[1,1]){
local constrnt`u' = "constraint `u' 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
qui `constrnt`u''
local v=`u'+100
local constrnt`u'_2 = "constraint `v' 3*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([3.item`i']_cons-([3.item`i']_cons+[3.item`i'] tt))"
qui `constrnt`u'_2'
}
if (`nbmoda_`i''==2 & resmat[1,`nbitems'+`i']!=testm[1,1]){
local constrnt`u' = "constraint `u' 2*([1.item`i']_cons-([1.item`i']_cons+[1.item`i'] tt))=([2.item`i']_cons-([2.item`i']_cons+[2.item`i'] tt))"
qui `constrnt`u''
}
}
* Définition du modèle
local mod "gsem "
local conformula = ""
forvalues i=1/`nbitems' {
local mod = "`mod'"+"(1.item`i'<-THETA@1)"
if (`nbmoda_`i''==3) {
local mod = "`mod'"+"(2.item`i'<-THETA@2)(3.item`i'<-THETA@3)"
}
else if (`nbmoda_`i''==2) {
local mod = "`mod'"+"(2.item`i'<-THETA@2)"
}
}
forvalues u=1/`nbdetect' {
local v=`difitems`u''
local mod = "`mod'"+"(1.item`v'<-THETA@1 tt)"
if (`nbmoda_`v''==3) {
local mod = "`mod'"+"(2.item`v'<-THETA@2 tt)(3.item`v'<-THETA@3 tt)"
}
else if (`nbmoda_`v''==2) {
local mod = "`mod'"+"(2.item`v'<-THETA@2 tt)"
}
local w= 100+`u'
local unif_`u'=0
if (resmat[1,`nbitems'+`v']!=testm[1,1] & `nbmoda_`v''==3) {
local conformula = "`conformula'" + "`u' " + "`w' "
local unif_`u'=1
}
else if (resmat[1,`nbitems'+`v']!=testm[1,1] & `nbmoda_`v''==2) {
local conformula = "`conformula'" + "`u' "
local unif_`u'=1
}
}
if ("`conformula'" != "") {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent constraint(`conformula')"
}
else {
local mod = "`mod'" + "(THETA<-tt), mlogit tol(0.01) iterate(500) latent(THETA) nocapslatent"
}
*calcul du modèle
`mod'
mat V=r(table)
mat W=V[1..2,1...]
* compilation
forvalues j=1/`nbitems' {
forvalues z=1/`nbmoda_`j'' {
mat outmat[`k',colnumb(outmat,"item`j'_`z'")] = W[1,colnumb(W,"`z'.item`j':_cons")]
}
}
* compilation DIF
forvalues u=1/`nbdetect' {
local j=`difitems`u''
forvalues z=1/`nbmoda_`j'' {
mat outmat[`k',colnumb(outmat,"dif_`u'_`z'")] = W[1,colnumb(W,"`z'.item`j':tt")]
}
mat outmat[`k',colnumb(outmat,"dif_detect_`u'")] = `j'
if (mod(`s',2)==0) {
mat outmat[`k',colnumb(outmat,"dif_detect_unif_`u'")] = `unif_`u''
}
}
* Stocker les items de DIF originaux
if (`nbdif' > 0) {
qui levelsof dif1
local ldif1 = r(levels)
local diff1: word 1 of `ldif1'
qui mat outmat[`k',colnumb(outmat,"real_dif_1")]=`diff1'
if (`nbdif' > 1) {
qui levelsof dif2
local ldif2 = r(levels)
local diff2: word 1 of `ldif2'
qui mat outmat[`k',colnumb(outmat,"real_dif_2")]=`diff2'
if (`nbdif' > 2) {
qui levelsof dif3
local ldif3 = r(levels)
local diff3: word 1 of `ldif3'
qui mat outmat[`k',colnumb(outmat,"real_dif_3")]=`diff3'
}
}
}
qui mat outmat[`k',colnumb(outmat,"beta")]=W[1,colnumb(W,"THETA:tt")]
qui mat outmat[`k',colnumb(outmat,"se_beta")]=W[2,colnumb(W,"THETA:tt")]
qui mat outmat[`k',colnumb(outmat,"lrt_passed")]=lrt_passed[1,1]
restore
}
log close
putexcel set "`path_res'/`s'`scen'_`Nn'_original.xls", sheet("outmat") replace
putexcel A1=matrix(outmat), colnames
}
}
}

BIN
Supplementaries.tar.gz Normal file

Binary file not shown.